实战01(根据当前时间创建文件)
import time
def create():
global name
localTime = time.strftime("%Y%m%d%H%M%S", time.localtime())
name = localTime + '.txt'
with open(name,'a') as file:
pass
if __name__ == '__main__':
amount = int(input('请输入需要生成的文件数:'))
for i in range(amount):
create()
print('file ' + str(i+1) +':' + name)
time.sleep(1)
print('生成文件成功!')
实战02(批量添加文件夹)
1 import os 2 for i in range(1,4): 3 p=r'D:\pythontest\Python10-2.py'+str(i) 4 print(p) 5 os.mkdir(p)
标签:实战,__,name,Python10,time,print From: https://www.cnblogs.com/ron312/p/16861558.html