_()内部和外部变量之间的差异
除了名字以外,这些类之间有什么区别吗?
class WithClass (): def __init__(self): self.value = "Bob" def my_func(self): print(self.value)class WithoutClass (): value = "Bob" def my_func(self): print(self.value)
如果我使用或不使用__init__方法来声明变量。value?
__init__
value
我主要担心的是,我会以一种方式使用它,而这会给我带来更多的问题。
梵蒂冈之花
慕容3067478
一只斗牛犬
相关分类