def calc_prod(lst):
def f():
def prod(x, y):
return x*y
return reduce(prod, lst)
return f
f = calc_prod([1, 2, 3, 4])
print f()
def f():
def prod(x, y):
return x*y
return reduce(prod, lst)
return f
f = calc_prod([1, 2, 3, 4])
print f()
2020-01-03
import math
def is_sqr(x):
return (math.sqrt(x) - int(math.sqrt(x)) == 0)
print filter(is_sqr, range(1, 101))
def is_sqr(x):
return (math.sqrt(x) - int(math.sqrt(x)) == 0)
print filter(is_sqr, range(1, 101))
2020-01-03
L=[x for x in range(1,101) if int(math.sqrt(x))**2==x]
2019-12-31
不鼓励这样访问,但是可以访问到
class Person(object):
def __init__(self, name, score):
self.name = name
self.__score = score
p = Person('Bob', 59)
print p.name
print p._Person__score
class Person(object):
def __init__(self, name, score):
self.name = name
self.__score = score
p = Person('Bob', 59)
print p.name
print p._Person__score
2019-12-25
import time
def performance(f):
def jishi(*args):
time1 = time.time()
result=f(*args)
time2 = time.time()
#print (time2 - time1)
print("call "+f.__name__+"() "+"in "+str(time2-time1))
return result
return jishi
def performance(f):
def jishi(*args):
time1 = time.time()
result=f(*args)
time2 = time.time()
#print (time2 - time1)
print("call "+f.__name__+"() "+"in "+str(time2-time1))
return result
return jishi
2019-12-12
def count():
fs=[]
for i in range(1,4):
def f(i):
return i*i
fs.append(f)
return fs
f1,f2,f3=count()
print f1(1),f2(2),f3(3)
fs=[]
for i in range(1,4):
def f(i):
return i*i
fs.append(f)
return fs
f1,f2,f3=count()
print f1(1),f2(2),f3(3)
2019-12-12
import math
def is_sqr(x):
return math.sqrt(x)*10%10==0
print filter(is_sqr, range(1, 101))
def is_sqr(x):
return math.sqrt(x)*10%10==0
print filter(is_sqr, range(1, 101))
2019-12-12
有没有大佬知道,代码里面的moviepy模块导入后可以使用,打包之后就显示没有这个模块。代码可以执行,打包后不能使用,就是因为打包没有讲这个模块打包了,可问题是已经打包-p 也使用了