#函数的默认参数必须放在参数列表的后面

#函数对全局变量可以直接读,要想对全局变量写,需要对全局变量声明global
#特殊:列表,字典等可进行修改,但不能重新进行赋值

name = 'maco'
def f():
    global name
    name = 'alex'
    print(name)

f()

 

相关文章:

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