摘要: import osos.mkdir('我的文件夹')#如果要要创建的文件夹存在,程序报错。#在创建文件夹之前,先判断创建的文件夹是否存在,不存在就创建新的。if not os.path.exists('我的文件夹2'): os.mkdir('我的文件夹2')#多级文件夹os.makedirsos.m 阅读全文
posted @ 2021-08-26 21:13 金涛拍岸 阅读(610) 评论(0) 推荐(0)
摘要: import osprint(os.path.join('F:\\万金鑫\Python\工程文件','2')) #告诉他路径 import osprint(os.getcwd()) #获得文件路径 阅读全文
posted @ 2021-08-25 22:12 金涛拍岸 阅读(38) 评论(0) 推荐(0)
摘要: with open('note.txt','r',encoding='utf-8')as f: print(f.readlines()) #读取! #写入with open('a.txt','w',encoding='utf-8') as a: #“w” a.write('你好?') a.write 阅读全文
posted @ 2021-08-25 22:11 金涛拍岸 阅读(52) 评论(0) 推荐(0)
摘要: import osfor file in os.scandir(): print(file.stat())#sizi=字节(大小),ctime=创建时间,mtime=修改时间,atime=最近访问时间 #时间戳转换 import time import datetimeprint(time.ctim 阅读全文
posted @ 2021-08-25 22:11 金涛拍岸 阅读(101) 评论(0) 推荐(0)
摘要: #内置import oslst = os.listdir()print(lst)for I in lst: if I.endswith('.py'): # 在当前文件夹里寻找以”.py“结尾的文件 print(I)print('____________________________________ 阅读全文
posted @ 2021-08-25 22:10 金涛拍岸 阅读(168) 评论(0) 推荐(0)
摘要: #临时文件from tempfile import TemporaryFilefile=TemporaryFile('w+')file.write('杨老师好')file.seek(0)print(file.readlines())print(file.name)#查路径input('1234567 阅读全文
posted @ 2021-08-25 22:09 金涛拍岸 阅读(235) 评论(0) 推荐(0)