def func(x): print("x is ", x) x = 2 print("Changed local x to ", x) x = 50func(x) print("x is still ", x)运行结果是:
('x is ', 50)
('Changed local x to ', 2)
('Changed local x to ', 2)
?????????
这里的X竟然还是50,这就是Python里所谓的局部变量。。。。。
('x is still ', 50)
('x is still ', 50)
浙公网安备 33010602011771号