说明:本文实例讲述了python删除过期文件的方法。分享给大家供大家参考。具体实现方法如下:
# remove all jpeg image files of an expired modification date = mtime
# you could also use creation date (ctime) or last access date (atime)
# os.stat(filename) returns (mode, ino, dev, nlink, uid, gid, si <weixin_38575456> 上传 | 大小:28kb
说明:本文研究的主要是Python处理文本换行符的相关内容,具体如下。
源文件每行后面都有回车,所以用下面输出时,中间会多了一行
try:
with open("F:\\hjt.txt" ) as f :
for line in f:
print(line)
except FileNotFoundError:
print("读取文件出错")
有两种方法处理:
1.print后面带 end=”,表示不换行
try:
with open("F:\\hjt.txt" ) <weixin_38690017> 上传 | 大小:40kb