1 class Text:
 2     def __init__(self):
 3         pass
 4     def big(self):
 5         n, m = 0, 0
 6         def a():
 7             nonlocal n
 8             n += 1
 9             print(n)
10             if n == 1:
11                 print('one')
12             elif n == 2:
13                 print('two')
14         a()
15         a()
16 if __name__ == '__main__':
17     text = Text()
18     text.big()

打印结果:

1
one
2
two

相关文章:

  • 2022-12-23
  • 2021-09-12
  • 2022-12-23
  • 2022-12-23
  • 2021-10-05
  • 2022-12-23
  • 2021-12-26
  • 2021-05-17
猜你喜欢
  • 2021-07-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-29
  • 2022-12-23
  • 2021-12-30
相关资源
相似解决方案