python 13 常用模块

一.time模块

1.time.time()获取当前时间戳,返回长整型

2.time.localtime() 获取当地结构化时间,time.gmtime()获取格林尼治时间  

 一图需要传入匹配格式,二图不需要传入匹配格式

  • 二[].random模块

choice([])列表中数组随机

sample(),数组中只选指定个数

uniform()1到3,随机

shuffle()打乱顺序

  • 三.os模块

1.os.path.dirname()获取该文件/文件夹所在文件夹的路径

2.os.path.abspath()获取该文件的绝对路径

3.__file__该文件的对象 

猜你喜欢

转载自www.cnblogs.com/MrYangjlPython/p/10140331.html