0
我想在Python中驗證一個json,這是一個來自URL的響應。我如何驗證它在Python中,以確保這個迴應是隻有JSON或不?是否有任何方法來驗證python中的json響應?
def SLRCLDQR011():
try:
url = 'http://someurl.com/q='
query = 'running shoes'
resp = requests.get(url + query)
except requests.exceptions.ConnectionError as e:
print 'Domain Name is not reachable'
except:
print "testcase {0} failed ".format(funcName)
logfile.write("testcase {0} failed ".format(funcName))
print "Unexpected error:", sys.exc_info()[0]
raise
請不要將您的功能命名爲。任何人都應該能夠告訴你函數在代碼的其他部分做了什麼? – IanAuld