ValueError:数据不能是字符串。在Python中

时间:2016-12-15 23:14:51

标签: python

   "Guys am trying python requests module to automate SOAP request and need help with it..Basically this is what i am doing. "

    body = '''<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Header>
    ...some code here....
    </rel:SubmitReq>
    </soapenv:Body>
    </soapenv:Envelope>
    '''

    files={ }
    with open("/home/xxx/yyy/zzz.jpg", "rb") as f:
        files = base64.b64encode(f.read())

    headers = {"Content-Type": "text/xml","Connection":  "Keep-Alive", "Authorization": "Basic xxxxxxxxxxxxxxxxxxxxx="}

    r = requests.post('URL PAth', verify=False, headers=headers, data=body,files=files)

    print r.status_code

    print r.content

'''问题是我们总是得到ValueError:数据不能是字符串。

有人可以指导我可能出现什么问题'''

0 个答案:

没有答案