Python 原始字符串中的ini文件:不解释新行

Python 原始字符串中的ini文件:不解释新行,python,string,newline,ini,configparser,Python,String,Newline,Ini,Configparser,我有一个来自Get请求的ini文件。我想把这个字符串写入一个文件。当我将此字符串写入文件或打印此字符串时,不会解释新行 userData = str(requests.get(url).content) file = open(FileINI, "w") file.write(userData) file.close() userData包含以下内容: [Foo]\n\nIsProduction = 0\n\n[Bar]\nkey = key1\n FileINI的内容是

我有一个来自Get请求的ini文件。我想把这个字符串写入一个文件。当我将此字符串写入文件或打印此字符串时,不会解释新行

userData = str(requests.get(url).content)
file = open(FileINI, "w")
file.write(userData)
file.close()
userData包含以下内容:

[Foo]\n\nIsProduction = 0\n\n[Bar]\nkey = key1\n
FileINI的内容是:

[Foo]\n\nIsProduction = 0\n\n[Bar]\nkey = key1\n
我尝试了repr函数和configParser,但没有用

更新

我发现当转换为字符串时,响应包含“\\n”,这就是为什么当我打印它时,它只给我\n。因此,替换\\n to \n使作业

打印(用户数据)显示什么?-这能回答你的问题吗?