class a:
def __init__(self):
self._b()#why here use _b,not b,What's the difference
self._c='cccc'#why here use _c,not c,What's the difference
def _b():
print 'bbbb'
class a:
def __init__(self):
self._b()#why here use _b,not b,What's the difference
self._c='cccc'#why here use _c,not c,What's the difference
def _b(self):
print 'bbbb'
b.py
from a import *
b=a()
b._b()
print b._c
其打印 BBBB BBBB BBBB BBBB CCCC
爲什麼可以打印出這些,不是_b和_c私有變量。
下面有兩種答案。文字和洞察力。有感知力的人試圖預測你真正想問什麼,而文字人士只是回答(寫得不好)的問題。兩者都是有效的,IMO。 – gahooa 2009-12-22 02:39:07