尝试实现QMEAN时出现Python缩进错误

2024-09-28 18:55:13 发布

您现在位置:Python中文网/ 问答频道 /正文

import json
import requests
url = "https://swissmodel.expasy.org/qmean/submit/"
# To upload from URL, put the URL as the structure
response = requests.post(url=url, data={"structure": 
"https://files.rcsb.org/download/1CRN.pdb", "email": "your@email.com"})

# When using Python requests - to upload from file, put the file in files
response = requests.post(url=url, data={"email": "your@email.com"}, files= 
{"structure": open('my_structure.pdb','r')}) 
print json.dumps(response.json(), indent=4, sort_keys=True)
{
"download_url": "https://swissmodel.expasy.org/qmean/qH7VxZ.json",
"error": "",
"meta": {
    "created": "2016-08-31 10:26:13.128564",
    "email": "your@email.com",
    "project_name": "Project",
    "results_page": "https://swissmodel.expasy.org/qmean/project/qH7VxZ/",
    "seqres_uploaded": false
},
"method": "QMEANDisCo",
"models": [
    {
        "modelid": "model_001",
        "name": "1CRN.pdb",
        "seqres": [
            {
                "atomseq": "TTCCPSIVARSNFNVCRLPGTPEAICATYTGCIIIPGATCPGDYAN",
                "chain_name": "A",
                "name": "seq_chain_0",
                "sequence": "TTCCPSIVARSNFNVCRLPGTPEAICATYTGCIIIPGATCPGDYAN"
            }
        ]
    }

我得到的错误是:

print json.dumps(response.json(), indent=4, sort_keys=True) IndentationError: unexpected indent

实际上,这是一个简单的缩进错误,我该如何解决它呢


Tags: thenamehttpsorgjsonurlemailresponse