0

I have an ini file brought from a Get request. I want to write this string to a file. when I write this string to a file or print this string the new lines are not interpreted

userData = str(requests.get(url).content)
file = open(FileINI, "w")
file.write(userData)
file.close()

userData contains something like :

[Foo]\n\nIsProduction = 0\n\n[Bar]\nkey = key1\n

The FileINI content is :

[Foo]\n\nIsProduction = 0\n\n[Bar]\nkey = key1\n

I tried the repr function, and configParser but no use

Update

I found out that the response contains "\\n" when converted to string, thats why when I print it it does give me only \n. So a replace \\n to \n made the job

blue
  • 525
  • 1
  • 8
  • 20

0 Answers0