By
Colbert337
更新日期:
文章目录
用于CGI接口测试,python 2.7.1亲测有效
talk is cheap , show me the code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| import urllib import urllib2
import ssl ssl._create_default_https_context = ssl._create_unverified_context
url = "https://api.mch.weixin.qq.com/papay/test"
print "url = " + url
test_data1 = "<?xml version='1.0' standalone=no><!- Our to do list data -><xml><test>" test_data2 = "a" test_data3 = "</test></xml>"
data = test_data1 + test_data2 *7 + test_data3
if len(data) > 20: print "data = " + data[0:20]+"..."+data[len(data)-20:] else: print "data = " + data
req = urllib2.Request(url = url,data =data)
res_data = urllib2.urlopen(req) res = res_data.read() print "response = " print res
|