【python】3.6バージョンhttp.clientネットワークリクエストの使用例

1500 ワード

ここでは、図霊ロボットを呼び出す例を示します.

#!/user/bin/python
#-*- coding:utf-8 -*-
import
urllib.parse
import
http.client
import
json
test_data = {'key': 'xxx', 'info': 'xxx', 'userid': 'xxx'}
test_data_url_encode = urllib.parse.urlencode(test_data)
request_url = "http://www.tuling123.com/openapi/api"
conn = http.client.HTTPConnection('www.tuling123.com')
header = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
conn.request(method="POST", url=request_url, headers=header, body=test_data_url_encode)
response = conn.getresponse()
#print(response.status)
#print(response.reason)
res = response.read()
#print(res)
resp = json.loads(res)
print(resp)最後にpythonの公式リンクを添付します.https://docs.python.org/3.6/library/http.client.html  
知行事務、専門移動事務プラットフォームhttps://zx.naton.cn/
オリジナルチーム
【総監】十二春秋之、[email protected];
【Master】zelo,[email protected];【運営】狼行天下、[email protected];
【製品デザイン】放浪猫、[email protected];【体験デザイン】ポケット、[email protected];
【iOS】コードを研ぐ作業員、[email protected];iMcG33K,[email protected];
【Android】人猿居士、[email protected];
考えの悟り、[email protected];
【java】チーフエンジニアMR_W,[email protected];【テスト】
土鏡が尋ねた[email protected]
;
【データ】喜楽多、[email protected];【安全】秘密にして、あなたは知っています.