Discuss / Python / 一个细节:addr的类型tuple不是str

一个细节:addr的类型tuple不是str

Topic source
print('the connection from %s:%s is closed' % addr)   # addr是一个tuple(IP,port),需要两个%s来接受数据。the connection from 127.0.0.1:20481 is closed
print(type(addr)) # tuple(IP,port)
print(type(sock)) # socket.socket

  • 1

Reply