I want to modify beta and n2 in Test.txt. However, f0.write() is completely rewriting all the contents. I present the current and expected outputs.
fo = open("Test.txt", "w") fo.write( "beta=1e-2") fo.write( "n2=5.0") fo.close() The contents of Test.txt is
beta=1e-1 n1=30.0 n2=50.0 The current output is
beta=1e-2n2=5.0 The expected output is
beta=1e-2 n1=30.0 n2=5.0