python built-in functions can be modified in the external environment variables
The key is if the details are simple variable type, but not if it is a container class variables, then no problem...
The following code:
class G:
pass
def f():
a=11
b=22
x=[1, 2, 3]
g=G()
g.abc=2
def iner():
global c # 如果想要把内部变量传递到外部环境里, 就必须先在内部函数里声明为全局变量
c=a+b
# b *=100 # 内部函数不能修改 简单型外部变量
x.append([4,5,6]) # 但是可以修改容器类外部变量, 比如list型的
print('x=', x)
print(a,b,c)
print(x)
g.abc=200
g.x=555
print(g.abc)
iner()
print(a,b,c)
print(x)
print(f'g.abc={g.abc}')
print(g.x)
operation result:
f()
x= [1, 2, 3, [4, 5, 6]]
11 22 33
[1, 2, 3, [4, 5, 6]]
200
11 22 33
[1, 2, 3, [4, 5, 6]]
g.abc=200
555