我的运行环境是python2.7的运行一段代码失败,初学者,在网上也找不到正确的回答,请帮忙
import socket host= '' port= 51423 s = socket.socket(socket.AF_INET,socket.SOCK_STREAM) s.setsockopt((socket.SOL_SOCKET,socket.SO_REUSEADDR,1) s.bind((host,port)) print "waiting for connections......." s.listen(1)
错误提示:
File "g:\python\socket\1.py", line 8
s.bind((host,port))
^
SyntaxError: invalid syntax