例子:
def test(obj):
try:
print float(obj)
except:
print '出错啦'
else:
print '没有出任何错误时,执行这里'
def test(obj):
try:
print float(obj)
except:
print '出错啦'
else:
print '没有出任何错误时,执行这里'
try 中的 Else非常不错,当只有Try语句中的部分没有出发异常,才会执行else后的内容。