python 建立文件夹并新建txt文件
import os
b = os.getcwd() + '\\test_txt\\'
print("Created directory:"+ "test_txt")
print("The created TXT files:")
if not os.path.exists(b):
os.makedirs(b)
for file in range(1,20):
print(str(file)+'.txt')
open(b+str(file)+'.txt', "w")
if __name__ == '__main__':new_txt()
效果如图: