python的类初始化
时间:2011-04-25 来源:孤独的猫
class book:
_author=''
_name=''
_page=0
price=0
_press=''
def _check(self,item):
if item=='':
return 0
else:
return 1
def show(self):
if self._check(self._author):
print(self._author)
else:
print('No value')
if self._check(self._name):
print(self._name)
else:
print('No value')
def setname(self,name):
self._name=name
def __init__(self,author,name):
self._author=author
self._name=name
a=book('Tom','A Wonderful Book')
a.show()
相关阅读 更多 +