close

undefined

Python 在 try except 之後,如果想要直接把 exception 印出來,可以使用下述的方式:

sentence = raw_input()
try:
    print(sentence)
except Exception as e:
    print(e)

這樣就可以印出 exception了,打完收工~

 

Reference:

1. https://stackoverflow.com/questions/1483429/how-to-print-an-error-in-python

arrow
arrow
    全站熱搜

    葛瑞斯肯 發表在 痞客邦 留言(0) 人氣()