python3 try except 实例

import socket
try:
    socket.setdefaulttimeout(2)
    s=socket.socket()
    s.connect(("211.144.208.7",23))
    ans=s.recv(2048)
    print (ans.decode("utf-8"))
except Exception as e:
    print(e)
try:
    print(1/0)
except (Exception) as e:
    print(e)
posted @ 2017-09-15 20:05  AbyssCE  阅读(190)  评论(0编辑  收藏  举报