python client使用http post 到server端的代码

让人生与事业结伴,让生命与使命同行。你要按你所想的去生活,否则,你迟早会按你所生活的去想。

import urllib, httplib
import utils
import json
class User: def __init__(self):
print 'a' def login(self, imsi, ua):
print "==============user start login=================="
input = {
"method" : "user.login",
"userName" : "",
"userPass" : "",
} input["sig"] = utils.getSignature(input)
params = urllib.urlencode(input)
headers = {
"user-agent" : ua,
"Appstore-clientType" : "android",
"Appstore-IMEI" : "123456789000000",
"Appstore-IMSI" : imsi
} try:
connection = httplib.HTTPConnection(utils.API_HOST)
connection.request("POST", "/api", params, headers)
response = connection.getresponse().read()
#print "=========" + response
connection.close()
except Exception, e :
print "========" + str(e) if "errorcode" in response or response is None:
return results = json.loads(response) return results["results"].encode("utf-8")

以上就是python client使用http post 到server端的代码。黄老师批评的时候像蒙蒙细雨,绵绵长长,而林老师总是暴风雨,那也好,快去快来。更多关于python client使用http post 到server端的代码请关注haodaima.com其它相关文章!

标签: client python