一个普通的例子
def func(x):
print('this is x:', x)
x = 2
print('this is new x:', x)
x = 50
func(x)
print('this is also x:', x)
>>>this is x: 50
>>>this is new x: 2
>>>this is also x: 50
第二个例子
def func():
global x
print('this is x:', x)
x = 2
print('this is new x:', x)
x = 50
func()
print('this is also x:' ,x)
>>>this is x: 50
>>>this is new x: 2
>>>this is also x: 2