格式化时间和 时间撮 random

. collections
namedtuple: 命名元组. 创建类
Counter: 计数器
deque: 双向队列
stack: 栈 先进后出
queue: 队列 先进先出
OrderedDict 有序字典. 浪费内存
defaultdict: 默认值字典
d = defaultdict(callable)
ret = d.get("周润发")

ret是 callable()

2. time模块
1. 时间戳. float 数字. 1970-01-01 00:00:00
2. 格式化时间. %Y-%m-%d %H:%M:%S %Y-%m-%d
3. 结构化时间. 把时间拆分了。
时间戳 -> 格式化时间
f = 10086
st = time.localtime(f)
s = time.strftime("%Y-%m-%d %H:%M:%S", st)
格式化时间 -> 时间戳
s = "2018-01-01 12:58:46"
st = time.strptime(s, "%Y-%m-%d %H:%M:%S")
f = time.mktime(st)

sleep()

. random
random.randint(start, end) [start, end]随机整数
random.choice() 随机选择
random.sample() 随机选择n个
. os和sys
os 和操作系统相关
sys 和解释器相关的
sys.path.clear()
原文地址:https://www.cnblogs.com/liurenli/p/9772914.html