I’d like to replace a certain number say 3.54 with 3.363 in multiple .inp files and save in place.
This is what I have written so far but I don’t know where the problem is !
so I would appreciate it if someone could have a look at this.
for i in range(1, 126):
file = 'C:/inp/' + str(i) +'.inp'
o2 = open(name=file, readOnly=False)
for line in ("file"):
file.write(line.replace('3.54', '3.363'))
file.close()
The for loop:
makes
lineequal to'f', then'i', then'l', then'e'.Try
Note that
line.replace('3.54', '3.363')is a bit dangerous. It will change13.54to13.363, for example. To protect against this, use regex.References to tools used:
filenames)