xml request issued post


# Python3 string wrap, add a backslash body to the right = ' <xml Version = "1.0" encoding = "UTF-8"??>' \ ' <COM>' \ ' <REQ name = "Shanghai - yo "> '\ ' <the USER_ID> yoyoketang </ the USER_ID> '\ ' <COMMODITY_ID> 123456 </ COMMODITY_ID> '\ ' <the SESSION_ID> absbnmasbnfmasbm1213 </ the SESSION_ID> '\ ' </ REQ> '\ ' </ the COM> ' # coding error encountered when performed on the body requests.post = R & lt encode (URL, Data = body.encode ( "UTF-. 8")) Print (R & lt. 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)

Guess you like

Origin www.cnblogs.com/yaohu/p/11593655.html