标签:迭代器 func 迭代 open 方式 写入 font time pytho
2 编写日志装饰器,实现功能如:一旦函数f1执行,则将消息2017-07-21 11:12:11 f1 run写入到文件中
注意:时间格式的获取
import time
time.strftime(‘%Y-%m-%d %X‘)
import time
def tim(func):
def wrapper(*args,**kwargs):
print(‘%s‘ %time.strftime(‘%y-%m-%d %X‘))
return func(*args,**kwargs)
return wrapper
3 判断下列数据类型是可迭代对象or迭代器
s=‘hello‘
l=[1,2,3,4]
t=(1,2,3)
d={‘a‘:1}
set={1,2,3}
f=open(‘a.txt‘)
4 分别用依赖索引和不依赖索引两种方式迭代上述对象
标签:迭代器 func 迭代 open 方式 写入 font time pytho
原文地址:http://www.cnblogs.com/654321cc/p/7019919.html