使用python将xml文件发送到http [英] send xml file to http using python
本文介绍了使用python将xml文件发送到http的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用python标准库将我的系统上的xml文件发送到http服务器?
how can i send an xml file on my system to an http server using python standard library??
推荐答案
import urllib
URL = "http://host.domain.tld/resource"
XML = "<xml />"
parameter = urllib.urlencode({'XML': XML})
a)使用HTTP POST
a) using HTTP POST
response = urllib.urlopen(URL, parameter)
print response.read()
b)使用HTTP GET
b) using HTTP GET
response = urllib.urlopen(URL + "?%s" % parameter)
print response.read()
这将是最简单的解决方案。
That would be the simplest solution.
这篇关于使用python将xml文件发送到http的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文