这样的代码:
import socket, sys
try:
address = ('127.0.0.1', 31500)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(address)
except Exception:
errType, errValue, errTraceback = sys.exc_info()
# or
# handle the Exception it throw out ?
我想得到的是像10060
这样的错误代码,这意味着connection time out
,感谢您的帮助:)
答案 0 :(得分:2)
使用
except EnvironmentError as e:
print e.errno