how can i send an xml file on my system to an http server using python standard library??
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
import urllib
URL = "http://host.domain.tld/resource"
XML = "<xml />"
parameter = urllib.urlencode({'XML': XML})
a) using HTTP POST
response = urllib.urlopen(URL, parameter)
print response.read()
b) using HTTP GET
response = urllib.urlopen(URL + "?%s" % parameter)
print response.read()
That would be the simplest solution.
回答2:
You can achieve that through a standard http post request.