Python 为什么不能捕获如下的除零异常?写了一个Button,点击后执行除零。
#coding=utf-8fromTkinterimport*try:defexe():tmp=10/0root=Tk()button=Button(text="go",...
#coding=utf-8
from Tkinter import *
try:
def exe():
tmp = 10/0
root = Tk()
button = Button(text = "go",command = exe)
button.pack()
root.mainloop()
except ZeroDivisionError:
print "除零异常"
finally:
print "END" 展开
from Tkinter import *
try:
def exe():
tmp = 10/0
root = Tk()
button = Button(text = "go",command = exe)
button.pack()
root.mainloop()
except ZeroDivisionError:
print "除零异常"
finally:
print "END" 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询