标签:https 改变 tps 例子 int lob http details 修改
https://blog.csdn.net/weixin_40894921/article/details/88528159
从上面给的例子中可以看出,它可以被用来全局的
class A: def f(self): a=2 def ff(): a=5#这里是无法改变a的 ff() return a a=A() print(a.f()) #输出: 2
如果在ff中申明为global
class A: def f(self): a=2 def ff(): global a a=5 ff() return a a=A() print(a.f()) #输出: 2
还是不行,如果尝试在ff中对a修改:
class A: def f(self): a=2 def ff(): global a a+=1 ff() return a a=A() print(a.f()) #输出: TypeError: unsupported operand type(s) for +=: ‘A‘ and ‘int‘
就会报以上错误。所以这个global是不能在类内的函数的函数使用的?
标签:https 改变 tps 例子 int lob http details 修改
原文地址:https://www.cnblogs.com/BlueBlueSea/p/13053627.html