【发布时间】:2022-01-20 13:38:40
【问题描述】:
我在 Google Colab 中运行以下代码并获得 The server encountered an internal error or misconfiguration and was unable to complete your request。如果我在运行命令时没有像下面那样传入变量$data,它运行得非常好。只有当我遍历文件并传递变量时它似乎失败了
import csv
import json
reader = csv.reader(open('/content/drive/MyDrive/file5.csv'))
for row in reader:
data = {"snps": row[0], "pop": "YRI", "r2_threshold": "0.9", "maf_threshold": "0.01"}
data = json.dumps(data)
data = "'{}'".format(data)
!curl -k -H "Content-Type: application/json" -X POST -d "$data" 'https://ldlink.nci.nih.gov/LDlinkRest/snpclip?token=e3e559472899'
这行得通:
!curl -k -H "Content-Type: application/json" -X POST -d '{"snps": "rs3\nrs4", "pop":"YRI", "r2_threshold": "0.1", "maf_threshold": "0.01"}' 'https://ldlink.nci.nih.gov/LDlinkRest/snpclip?token=e3e559472899'
【问题讨论】:
-
首先使用请求,因为它很容易管理它的属性。还可以尝试打印出您传递给请求的值,以便您知道错误发生在哪一行。
标签: python curl jupyter-notebook google-colaboratory