import string
def format_name(s):
return s.title()
print map(format_name, ['adam', 'LISA', 'barT'])
title函数可以将字符串转化为标题形式,即首字母大写,其他字母小写
def format_name(s):
return s.title()
print map(format_name, ['adam', 'LISA', 'barT'])
title函数可以将字符串转化为标题形式,即首字母大写,其他字母小写
2017-08-08
print isinstance(t,Person),isinstance(t,Student),isinstance(t,Teacher),isinstance(t,object)
2017-08-08
import time
def performance(f):
def fn(x):
print 'call '+f.__name__+'() in'+str(time.time())
return f(x)
return fn
@performance
def factorial(n):
return reduce(lambda x,y: x*y, range(1, n+1))
print factorial(10)
def performance(f):
def fn(x):
print 'call '+f.__name__+'() in'+str(time.time())
return f(x)
return fn
@performance
def factorial(n):
return reduce(lambda x,y: x*y, range(1, n+1))
print factorial(10)
2017-08-08
class Person(object):
def __init__(*args):
pass
xiaoming = Person('Xiao Ming', 'Male', '1990-1-1', job='Student')
print xiaoming.name
print xiaoming.job
def __init__(*args):
pass
xiaoming = Person('Xiao Ming', 'Male', '1990-1-1', job='Student')
print xiaoming.name
print xiaoming.job
2017-08-07
觉着难得同学有认真看老师的代码吗?建议你多看几遍代码,了解其中的思想。而不是在这里吵着说这门课怎么样? 请问,你学习这门课话一分钱了吗?
2017-08-07