如何从响应中获取xml内容并在Python中作为post发送回

如何从响应中获取xml内容并在Python中作为post发送回,python,Python,我正在使用GET检索XML数据,我需要编辑XML中的一些字段,并使用POST更新服务器中的数据 在Python中,我有: import requests as req url = "http://www.blabla.ok/api/categories/2" resp = req.get(url) dataString = resp.text #.... some manipulations in datastring #finally I need to pass the

我正在使用GET检索XML数据,我需要编辑XML中的一些字段,并使用POST更新服务器中的数据

在Python中,我有:

import requests as req
url = "http://www.blabla.ok/api/categories/2"
resp = req.get(url)
dataString  = resp.text
#.... some manipulations in datastring
#finally I need to pass the dataString as value of 'putXML' key 
req.post(url, data=dataString, headers={'Content-Type':'application/xml; charset=UTF-8'})
我如何指定“data=dataString”是putXML的值?

请参考,如果这无助于让我们知道。因此,您获得了数据字符串,然后应用更新。更改XML后,将其发送到post请求。我希望这会有帮助。