I have a config file with the following contents: service A = { params { dir = "c:\test", username = "test", password = "test" } } I want to find username and replace the value with another value. I don't know what the username value in advance though. How to do it in python?