常用模块使用

Time

时间戳:timestamp指的是从1970.1.1到现在的时间差,它是一个浮点型数据。通过time.time获取

local time:本地时间指的是计算机所在的地区时间 time.localtime及time.gmtime返回的是结构化时间

mktime:他能将一个结构化时间转化成时间戳

time.strpttime(string[,foramt]):把一个格式化时间转化为struct_time.实际上它和strftime是逆操作

OS

os.path.abspath(path)  返回path规范化的绝对路径
os.path.split(path)  将path分割成目录和文件名二元组返回
os.path.dirname(path)  返回path的目录。其实就是os.path.split(path)的第一个元素
os.path.basename(path)  返回path最后的文件名。如何path以/或结尾,那么就会返回空值。即os.path.split(path)的第二个元素
os.path.isfile(path)  如果path是一个存在的文件,返回True。否则返回False
os.path.isdir(path)  如果path是一个存在的目录,则返回True。否则返回False
os.path.join(path1[, path2[, ...]])  将多个路径组合后返回,第一个绝对路径之前的参数将被忽略
os.path.getatime(path)  返回path所指向的文件或者目录的最后存取时间
os.path.getmtime(path)  返回path所指向的文件或者目录的最后修改时间
os.path.getsize(path) 返回path的大小
原文地址:https://www.cnblogs.com/AllenZhou/p/9457362.html