2010-02-08 29 views

回答

5
>>> try: 
...  0/0 
... except Exception,e: 
...  print e.message 
... 
integer division or modulo by zero 

或在Python 2.6及以上,e.args寻找类似PERROR(),因为BaseException.message has been deprecated

>>> try: 
...  0/0 
... except Exception,e: 
...  print e.args 
... 
('integer division or modulo by zero',) 
+0

我使用python 2.6,因此电子商务。参数工作正常。谢谢 – 2010-02-08 07:11:43

-2
try: 
    pass 
except Exception, err: 
    print err 
相关问题