Python/Arcpy创建文本文件

#import os
>>> target_folder = ‘D:\T20161202’
… file_names=(‘BOUAN’,’BOULK’,’BOUNT’,’BOUPT’,’CTRLK’,’CTRPT’,’HYDAN’,’HYDLK’,’HYDNT’,’HYDPT’,’PIPAN’,’PIPLK’,’PIPNT’,’PIPPT’,’RESAN’,’RESLK’,’RESNT’,’RESPT’,’ROAAN’,’ROALK’,’ROANT’,’ROAPT’,’TERAN’,’TERLK’,’TERNT’,’TERPT’,’VEGAN’,’VEGLK’,’VEGNT’,’VEGPT’)
… for file_name in file_names:
…     file_name_ext = file_name+’.txt’
…     file_path = os.path.join(target_folder,file_name_ext)
…     print file_path
…     if not os.path.exists(file_path):
…         f=open(file_path,’w’)
…         f.close()        
…         
D:\T20161202\BOUAN.txt
D:\T20161202\BOULK.txt
D:\T20161202\BOUNT.txt
D:\T20161202\BOUPT.txt
D:\T20161202\CTRLK.txt
D:\T20161202\CTRPT.txt
D:\T20161202\HYDAN.txt
D:\T20161202\HYDLK.txt
D:\T20161202\HYDNT.txt
D:\T20161202\HYDPT.txt
D:\T20161202\PIPAN.txt
D:\T20161202\PIPLK.txt
D:\T20161202\PIPNT.txt
D:\T20161202\PIPPT.txt
D:\T20161202\RESAN.txt
D:\T20161202\RESLK.txt
D:\T20161202\RESNT.txt
D:\T20161202\RESPT.txt
D:\T20161202\ROAAN.txt
D:\T20161202\ROALK.txt
D:\T20161202\ROANT.txt
D:\T20161202\ROAPT.txt
D:\T20161202\TERAN.txt
D:\T20161202\TERLK.txt
D:\T20161202\TERNT.txt
D:\T20161202\TERPT.txt
D:\T20161202\VEGAN.txt
D:\T20161202\VEGLK.txt
D:\T20161202\VEGNT.txt
D:\T20161202\VEGPT.txt

转载自:https://blog.csdn.net/a_dev/article/details/54344269

You may also like...