# 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)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。