# a = 10
# b = 0
# c = 5
# try:
# print("a的值是:%d,b的值是:%d"%(a,b))
#
# f = c.open("a.txt")
# print(f)
# d = a / b
# print("%d除以%d的值为:%d"%(a,b,d))
# except (ZeroDivisionError,AttributeError) as msg:
# print("程序出错了")
# print(msg)
# finally:
# print("程序运行结束了~")
# 函数的嵌套
# import time
# try:
# f = open("test.txt")
# try:
# while true:
# content = f.readline()
# if len(content) == 0:
# break
# time.sleep(2)
# print(content)
# finally:
# print("程序运行结束~")
# f.close()
# print("关闭文件")
# except:
# print("没有这个文件")
def test1():
print("--test1-1--")
print(num)
print("--test1-2--")
def test2():
print("--test2-1--")
test1()
print("--test2-2--")
def test3():
try:
print("--test3-1--")
test2()
print("--test3-2--")
except Exception as result:
print("捕获到了异常~")
print(result)
print("--test4-1--")
test3()
print("--华丽的分割线--")
test2()
Python中函数嵌套以及函数嵌套的继承
猜你喜欢
转载自blog.csdn.net/wyqwilliam/article/details/83962009
今日推荐
周排行