批量创建txt文件,并统一命名,在所有文件中写入要求的语句。
#文件个数
num=5def main():#txt文件的存放路径desktop_path = "C:\\Users\\Zhang\\Desktop\\aaa\\"count=0for i in range(num):#命名格式full_path = desktop_path + "blxw_" + str(count) + '.txt'file = open(full_path, 'w')#写入的语句file.write("hello world!")print(full_path)count+=1if __name__ == '__main__':main()