【发布时间】:2020-06-13 08:58:02
【问题描述】:
我正在调用一个似乎只返回文本的 Rest API。 例子
gma:AciX8_0002 假设蛋白
我想获取 json 格式的数据。 在 Postman 中,我尝试添加标题内容类型 application/json 但仍然得到文本。 这是否意味着 Rest API 无法返回 json?
在这种情况下,在 python 中,我是否需要手动构建 json 文件,如下所示:
list = []
try:
with open(realfilename, "r") as reader:
for line in reader:
if line.strip(): # fix problem: do not parse empty lines
singleline= json.loads(line)
谢谢,彼得
【问题讨论】:
标签: python json rest python-requests