def log(f):
print('call ' + f.__name__ + '()...')
return f
这样可以吗?
print('call ' + f.__name__ + '()...')
return f
这样可以吗?
2016-08-31
import os.path
print os.path.isdir(r'/data/webroot/resource/python')
print os.path.isfile(r'/data/webroot/resource/python/test.txt')
输出都是false
print os.path.isdir(r'/data/webroot/resource/python')
print os.path.isfile(r'/data/webroot/resource/python/test.txt')
输出都是false
2016-08-30
def count():
fs = []
for i in range(1, 4):
L=i*i
fs.append(L)
return fs
f1, f2, f3 = count()
print f1, f2, f3
fs = []
for i in range(1, 4):
L=i*i
fs.append(L)
return fs
f1, f2, f3 = count()
print f1, f2, f3
2016-08-29
import math
def is_sqr(x):
if x and math.sqrt(x)%1==0:
return x
print filter(is_sqr, range(1, 101))
def is_sqr(x):
if x and math.sqrt(x)%1==0:
return x
print filter(is_sqr, range(1, 101))
2016-08-29
class Person(object):
def __init__(self,name,gender,birth,**job):
self.name=name
self.gender=gender
self.birth=birth
self.job=job
xiaoming = Person('Xiao Ming', 'Male', '1990-1-1', job='Student')
print xiaoming.name
print xiaoming.job
这样就简单好理解
def __init__(self,name,gender,birth,**job):
self.name=name
self.gender=gender
self.birth=birth
self.job=job
xiaoming = Person('Xiao Ming', 'Male', '1990-1-1', job='Student')
print xiaoming.name
print xiaoming.job
这样就简单好理解
2016-08-29
import math
def is_sqr(x):
return math.sqrt(x) % 1 == 0
print filter(is_sqr, range(1, 100))
def is_sqr(x):
return math.sqrt(x) % 1 == 0
print filter(is_sqr, range(1, 100))
2016-08-29
def format_name(s):
return s[0].upper()+s[1:].lower()
print map(format_name, ['adam', 'LISA', 'barT'])
return s[0].upper()+s[1:].lower()
print map(format_name, ['adam', 'LISA', 'barT'])
2016-08-28