class Person(object):
count=0
def __init__(self,name):
self.name=name
Person.count=Person.count+1
p1 = Person('Bob')
print Person.count
p2 = Person('Alice')
print Person.count
p3 = Person('Tim')
print Person.count
count=0
def __init__(self,name):
self.name=name
Person.count=Person.count+1
p1 = Person('Bob')
print Person.count
p2 = Person('Alice')
print Person.count
p3 = Person('Tim')
print Person.count
2015-04-16
def __init__(self, name, gender, **kw):
self.name = name
self.gender = gender
for k, v in kw.iteritems():
setattr(self, k, v)
这道题前几天才讲过,又忘记了,嗷嗷嗷
self.name = name
self.gender = gender
for k, v in kw.iteritems():
setattr(self, k, v)
这道题前几天才讲过,又忘记了,嗷嗷嗷
2015-04-16
class Students(object):
def read(self):
return r'["Tim","Bob","Alice"]'
def read(self):
return r'["Tim","Bob","Alice"]'
2015-04-15
class Person():
pass
xiaoming = Person()
xiaohong = Person()
print xiaoming
print xiaohong
print xiaoming==xiaohong
pass
xiaoming = Person()
xiaohong = Person()
print xiaoming
print xiaohong
print xiaoming==xiaohong
2015-04-15
def cmp_ignore_case(s1, s2):
return cmp(s1.lower(),s2.lower())
print sorted(['bob', 'about', 'Zoo', 'Credit'], cmp_ignore_case)
return cmp(s1.lower(),s2.lower())
print sorted(['bob', 'about', 'Zoo', 'Credit'], cmp_ignore_case)
2015-04-15
最新回答 / 人間世界
def __init__(self, name, score): self.name = name if score<=100: self.__score = score else: raise ValueError('wrong')
2015-04-14