python os 模块文件常用操作
123456
import os
#回去当前文件路径
os.path.realpath(__file__)
#获取文件是否存在
os.path.exists(filepath)
#获取文件大小
os.path.getsize(filepath)
#判断路径是否是文件夹
os.path.isdir(filepath)
#获取文件夹的文件列表
os.listdir(filepath)
#文件路径拼接
os.path.join(dirpath, filename)
#获取文件的上级路径
os.path.split(os.path.realpath(__file__))[0]
#删除文件
os.remove(filepath)
#生成文件夹
os.makedirs(dirpath)
#获取文件生成的时间
os.path.getmtime(filepath)