如何消除通过POSTreques发送的XML中的换行符

2024-04-29 14:37:17 发布

您现在位置:Python中文网/ 问答频道 /正文

我正试图通过POST请求发送.xml文件:

files = {"FileName": open (path_to_file.xml, "rb")}
requests.post(url, files=files)

但从客户端发送的文件

  <protection>
     <create name="domain1/domain2/>
     <allowed name="domain1"/>
     <allowed name="domain2"/>
  </protection>

在服务器端接收为

  <protection>

     <create name="domain1/domain2/>

     <allowed name="domain1"/>

     <allowed name="domain2"/>

  </protection>

有人面对过这样的问题吗


Tags: 文件topathnamecreatefilesxmlopen