鎺ュ彛鏌ヨ鏂规硶
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了鎺ュ彛鏌ヨ鏂规硶相关的知识,希望对你有一定的参考价值。
鏍囩锛?a href='http://www.mamicode.com/so/1/%e6%96%b9%e6%b3%95' title='鏂规硶'>鏂规硶
ror pytho ons err 鎺ュ彛鏂囨。 erro sop linimport requests
import json
import traceback
"""鎺ュ彛鏌ヨ"""
def GetSop(url,opid,queryvalue):
"""data_query_payload鐨勯厤缃牴鎹帴鍙f枃妗f潵"""
data_query_payload={
"authcode":鈥?11鈥? "params":{
"vttype":鈥榓鈥?
"vt":vt
}
}
"""headers鏍规嵁瀹為檯鎵撳紑鐨勭綉椤靛ご閰嶇疆"""
headers = {
"Content-Type":"application/json"
}
try:
"""鍙互浣跨敤requests.post().json()鏉ヤ唬鏇夸互涓嬩笁琛屼唬鐮?""
reponse = requests.post(url,headers=headers,data=json.dumps(data_query_payload))
r = reponse.text
queryjson = json.loads(r)
res = queryjson[鈥榙ata鈥榏
except:
traceback.print_exc()
res = 鈥榚rror鈥? return res
"""txt鏂囦欢璇诲彇涓哄垪琛?""
def TxtToList(infile):
res = []
with open(infile,鈥榬鈥? as f:
for line in f.readlines():
c = line.strip().strip(鈥榎n鈥?.split(鈥?鈥?
res.extend(c)
return res
"""鏁版嵁瀛樺叆txt鏂囦欢"""
with open(outfile,鈥榳鈥? as f:
res = GetSop(url,opid,queryvalue)
if res!=[]:
f.write(str(res)+鈥榎n鈥?
以上是关于鎺ュ彛鏌ヨ鏂规硶的主要内容,如果未能解决你的问题,请参考以下文章
涓€瀵逛竴鍏宠仈鏌ヨ鏃朵娇鐢╮elation杩炶疮鎿嶄綔鏌ヨ鍚庯紝璋冪敤getLastSql()鏂规硶杈撳嚭鐨剆ql璇彞