_()内部和外部变量之间的差异
除了名字以外,这些类之间有什么区别吗?
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
我主要担心的是,我会以一种方式使用它,而这会给我带来更多的问题。
翻过高山走不出你
开心每一天1111
蝴蝶不菲
相关分类