首页 > 其他 > 详细

格式化时间和 时间撮 random

时间:2018-10-11 16:27:15      阅读:143      评论:0      收藏:0      [点我收藏+]
. 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()

格式化时间和 时间撮 random

原文:https://www.cnblogs.com/liurenli/p/9772914.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!