input接收的全部輸入默認都是字符串格式python
一、%s表明字符串佔位符socket
conn, client_addr = phone.accept() print(conn) print(client_addr) print('got a new connection from %s' % (client_addr, )) """ <socket.socket fd=4, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 8080), raddr=('127.0.0.1', 55925)> ('127.0.0.1', 65197) got a new connection from ('127.0.0.1', 65197) """
二、%d是數字佔位符spa
>>> "金額:¥%d 元" % 1.5000 '金額:¥1 元'
佔位符%d只能傳遞十進制整數。blog
三、佔位符%f默認保留6爲小數位,而第7位根據四捨五入取值字符串
>>>'%f' % 1.12345678 '1.123457'