xml发post请求


# python3字符串换行,在右边加个反斜杠 body = '<?xml version="1.0" encoding = "UTF-8"?>' \ '<COM>' \ '<REQ name="上海-悠悠">' \ '<USER_ID>yoyoketang</USER_ID>' \ '<commodity_ID>123456</commodity_ID>' \ '<SESSION_ID>absbnmasbnfmasbm1213</SESSION_ID>' \ '</REQ>' \ '</COM>' # 遇到编码报错时候,对body进行encode r = requests.post(url, data=body.encode("utf-8")) print(r.text)

 

curpath = os.path.dirname(os.path.realpath(__file__)) xmlpath = os.path.join(curpath, "body1_xml") with open(xmlpath, encoding="utf-8") as fp: body = fp.read() # 读取xml文件 print(body)

相关文章

php输出xml格式字符串
J2ME Mobile 3D入门教程系列文章之一
XML轻松学习手册
XML入门的常见问题(一)
XML入门的常见问题(三)
XML轻松学习手册(2)XML概念