python - Python:发布 xml 文件
问题描述
我的xml文件:
<?xml version="1.0" ?>
<Task>
<Date>2020-06-24</Date>
<Time>10:40</Time>
<Main>
<Type>Car</Type>
<Task1>Something</Task1>
<Task2>Something</Task2>
<Task3>Something</Task3>
<Task4>Something</Task4>
<Task5>RESULT</Task5>
<Task6>1</Task6>
<Task7>103</Task7>
<Bill>
<Type>$</Type>
<Amount>100</Amount>
</Bill>
<Handball>false</Handball>
<Football>false</Football>
<Book>false</Book>
</Main>
</Task>
我的代码.py
xmlFile = 'test.xml'
API_URL = XXX
with open(xmlFile) as xml:
r= requests.post(API_URL, data=xmlFile)
print(r.text)
结果:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Status>
<Code>ERROR_FORMAT_INVALID</Code>
<Description>The supplied data could not be imported in the stated input format.</Description>
</Status>
<Status>
<Code>ERROR</Code>
<Description>The supplied data could not be imported in the stated input format - [XML2Array] Error parsing the XML string.</Description>
</Status>
</Response>
我想要的是:
我有 200 个 XML 文件要发布(逐个文件)并接收数据。在这种情况下,请指定类型 $ 和金额“100”。我知道我会得到不同的结果,这就是为什么我想将所有 200 个 xml 文件的结果保存到一个 txt 文件中。
如下所示,我收到此错误。我怎样才能解决这个问题?
先感谢您
解决方案
推荐阅读
- android - Android防止在清除数据事件上删除应用程序脱机数据或数据库
- php - 无法在控制器中获取用户 ID 并且 Auth::check() 不起作用 - Laravel 5.8
- sql - 批量插入文件列表
- c# - 如何使用 MuPDF 库在 Xamarin.android 中垂直滑动 pdf 页面
- python - 将一系列值随机插入 pd.dataframe
- java - 当 CPU 使用率为 100% 时,使用 Shiro 登录过程需要太多时间
- python - 图像的 Python 图像
- javascript - 如果对象返回 true,则设置 ngModel
- r - 如何在 R 中绘制概率密度函数?
- javascript - 从文本框 id 中选择值到 PHP