Python中模块、类、函数、实例调用案例

19 a = '我是模块中的变量a'
20 
21 def hi():
22     a = '我是函数里的变量a'
23     print('函数“hi”已经运行!')
24 
25 class Go2:
26     a = '我是类2中的变量a'
27     def do2(self):
28         print('函数“do2”已经运行!')
29 
30 print(a)  # 打印变量“a”
31 
32 hi()  # 调用函数“hi”
33 
34 A = Go2()  # 实例化“Go2”类
35 print(A.a)  # 打印实例属性“a”
36 A.do2()  # 调用实例方法“do2”
原文地址:https://www.cnblogs.com/Through-Target/p/12149149.html