Python replace value in text file Problem : I have a settings file which is test.py. in this file i have to replace some values like ORDER_PAIRS = 10 to --> ORDER_PAIRS = new value
and overwrite to the test.py file again how can i do that?

thanks..

FileName = "test.py"

# Open file and replace line
with open(FileName) as f:
    updatedString = f.read().replace("ORDER_PAIRS = 10", "ORDER_PAIRS = " + str(6))

# Write updated string to file
with open(FileName, "w") as f:
    f.write(updatedString)