4 批量创建文件操作
1 import os 2 import datetime 3 import time 4 5 while True: 6 path = input('请输入文件保存地址:') 7 num = int(input('请输入创建文件的数量:')) 8 for i in range(num): 9 t = datetime.datetime.now() 10 file = os.path.join(path,t.strftime('%Y%m%d%H%M%S') + '.txt') 11 open(file,'w',encoding='utf-8') 12 time.sleep(1) 13 i += 1 14 print('创建成功!') 15 os.startfile(path)