📅  最后修改于: 2022-03-11 14:46:11.026000             🧑  作者: Mango
globalvar = "flower"
def editglobalvar():
global globalvar # accesses the "globalvar" variable, so when we change it
# it won't assign the new value to a local variable,
# not changing the value of the global variable
globalvar = "good" # assigning new value
print(globalvar) # outputs "flower"
# if we didnt use the "global" keyword in the function, it would print out
# "flower"