标签:port NPU local count += 方式 print wrap 关键字
def func():
for i in range(101):
if i % 7 == 0:
yield i
for i in func():
print(i)
import time
def wrapper(func_name):
def inner(*args,**kwargs):
start_time = time.time()
ret = func_name(*args,**kwargs)
end_time = time.time()
print('函数执行耗时%s秒' % (end_time-start_time))
return inner
@wrapper
def func():
time.sleep(3)
func()
import time
birth = input('输入你的生日(1996-05-12):').strip()
if birth == '':
birth = '1996-05-12'
def SumDay(birthday,count=0):
birthday = time.strptime(birth,'%Y-%m-%d')
for year in range(birthday.tm_year,time.localtime().tm_year+1):
if year % 100 != 0 and year % 4 == 0:
count += 366
else:
count +=365
else:
count += birthday.tm_yday
return count
day = SumDay(birth)
print(f'你活了{day}天')
标签:port NPU local count += 方式 print wrap 关键字
原文地址:https://www.cnblogs.com/meilong/p/tuo-chan-ban-di-yi-ci-bu-ke-xi-ti.html