Can you explain why I have problems with 'with open(out, "w") as k:'? I would like to create a script to use for ArcGIS to add to each file in the folder with text extension 'Hellow'.
I guess everything because of fileName[:-4] + ".txt",so Python can not define and write in each file. However, I don't know how to correct it.
import arcpy
inPut = r'C:\12'
arcpy.env.workspace = inPut
myList = arcpy.ListFiles()
for fileName in myList:
if fileName.endswith(".txt"):
out = fileName[:-4] + ".txt"
with open(out, "w") as k:
k.write('Hellow')