#coding=utf-8
a=5
def test():
    global a
    print(a)
test()

输出

 5

 

例子

#coding=utf-8
a=5
def test():
    global a
    a=10
test()
print(a)

输出

10

 

相关文章:

  • 2022-12-23
  • 2021-07-08
  • 2021-06-03
  • 2021-10-28
  • 2022-12-23
  • 2022-12-23
  • 2022-01-06
  • 2021-12-26
猜你喜欢
  • 2021-09-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-17
  • 2021-10-03
相关资源
相似解决方案