也可以这么写
class People(object):
def __init__(self,name,gender,birth,*args):
self.name = name
self.gender = gender
self.birth = birth
self.args = args
xiaoming = Person('Xiao Ming', 'Male', '1990-1-1', job='Student')
print xiaoming.name
print xiaoming.job
class People(object):
def __init__(self,name,gender,birth,*args):
self.name = name
self.gender = gender
self.birth = birth
self.args = args
xiaoming = Person('Xiao Ming', 'Male', '1990-1-1', job='Student')
print xiaoming.name
print xiaoming.job
2015-08-17
按这个代码输出s就变得奇葩了。。。。只要@performance()里填的不是ms而是其他字符,显示出的数值都是s为单位的值,然后再接这个字符。。。。。。。。
2015-08-17
class Fib(object):
lst = [0,1]
def __init__(self, num):
self.num = num
for x in range(1,num-1):
Fib.lst.append(sum(Fib.lst[-2:]))
def __len__(self):
return self.num
def __str__(self):
return '%s' % self.lst
f = Fib(10)
print f
print len(f)
lst = [0,1]
def __init__(self, num):
self.num = num
for x in range(1,num-1):
Fib.lst.append(sum(Fib.lst[-2:]))
def __len__(self):
return self.num
def __str__(self):
return '%s' % self.lst
f = Fib(10)
print f
print len(f)
2015-08-17
def cmp_ignore_case(s1, s2):
if s1.lower() < s2.lower():
return -1
if s1.lower() > s2.lower():
return 1
print sorted(['bob', 'about', 'Zoo', 'Credit'], cmp_ignore_case)
没想到我这笨人也能写出来:)
if s1.lower() < s2.lower():
return -1
if s1.lower() > s2.lower():
return 1
print sorted(['bob', 'about', 'Zoo', 'Credit'], cmp_ignore_case)
没想到我这笨人也能写出来:)
2015-08-15