This is probably a simple fix, but having a little trouble getting my head around it; I'm reading lines from a different script, and want to replace a line with a variable, however it replaces it with box1
instead of the values 55, 55.7
box1 = 55, 55.7
box2 = -9, -7
with open('parttest', 'r') as file :
filedata = file.read()
filedata = filedata.replace('box_lat', 'box1')
filedata = filedata.replace('box_lon', 'box2')
with open('buildtest', 'w') as file:
file.write(filedata)
See Question&Answers more detail:os