# coding:utf-8
import requests
url = "http://httpbin.org/post"
# python3字符串换行,在右边加个反斜杠
body ='' \ '' \ '' \ 'yoyoketang' \
'123456' \ 'absbnmasbnfmasbm1213' \
'' \ ''
# 遇到编码报错时候,对body进行encode
r = requests.post(url, data=body.encode("utf-8"))
print(r.text)
=========================================
import os
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)