0

像这样的代码:

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 ?

我想要得到的是 errcode 10060,这意味着connection time out,感谢您的帮助:)

4

1 回答 1

2

采用

except EnvironmentError as e:
    print e.errno
于 2012-09-19T05:02:00.523 回答