I have written following program for my project purpose.
import glob
import os
path = "/home/madhusudan/1/*.txt"
files = glob.glob(path)
s1 = "<add>\n<doc>\n\t<field name = \"id\">"
s2 = "</field>\n"
s3 = "<field name = \"features\">"
s4 = "</doc>\n</add>"
i = 150
for file in files:
f = open(file,"r")
str = f.read()
file1 = "/home/madhusudan/2/"+os.path.splitext(os.path.basename(file))[0] + ".xml"
f1 = open(file1,"w")
content = s1 + str(i) + s2 + s3 + f.read() + s2 + s4
f1.write(content)
i = i + 1
While running this code I am getting following error:
Traceback (most recent call last):
File "test.py", line 18, in <module>
id1 = str(i)
TypeError: 'str' object is not callable
Can anyone help me to solve this?
str.str = f.read()shows that you are obviously not interested in keeping access to the builtinstrfunction/type. That's ok, but you should be aware that you should stand by that. (SCNR)