我正在尝试编写用于检查 JSON 请求的自动化测试。因此,当我运行以下代码时,出现回溯错误:
json1=query_link1.json
json2 = json.loads(json1)
例外:
Traceback (most recent call last):
File "Productapicheck.py", line 45, in <module>
query_product_api()
File "Productapicheck.py", line 34, in query_product_api
json2 = json.loads(json1)
File "/usr/lib/python2.6/json/__init__.py", line 307, in loads
return _default_decoder.decode(s)
File "/usr/lib/python2.6/json/decoder.py", line 319, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
TypeError: expected string or buffer