import xmltodict
s = {
'name': 'GOOG', 'shares': 100, 'price':490.1 }
print(xmltodict.unparse(s, full_document=False))
<name>GOOG</name><shares>100</shares><price>490.1</price>
import requests
url="http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL"
#headers = {'content-type': 'application/soap+xml'}
headers = {
'content-type': 'text/xml'}
body = """<?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:ns0="http://ws.cdyne.com/WeatherWS/" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP-ENV:Header/> <ns1:Body><ns0:GetWeatherInformation/></ns1:Body> </SOAP-ENV:Envelope>"""
response = requests.post(url,data=body,headers=headers)
print response.content
參考
https://gist.github.com/toast38coza/17e2ad6c2cfa2e96b0b1
This article is Python visuali
Every year at the beginning of