2016-08-02 6 views
1

banner["STATUS"]["Description"]を印刷すると、空の値が得られますか?python json print空の値

banner = { 
    "STATUS":[ 
    { 
     "STATUS": "S", 
     "When": 1470157636, 
     "Code": 11, 
     "Msg": "Summary", 
     "Description": "nsgminer 0.9.2" 
    } 
    ], 
    "SUMMARY": [ 
    { 
     "Elapsed":1502, 
     "MHS av":0.00, 
     "Found Blocks":0, 
     "Getworks":58, 
     "Accepted":0, 
     "Rejected":0, 
     "Hardware Errors":0, 
     "Utility":0.00, 
     "Discarded":116, 
     "Stale":0, 
     "Get Failures":2, 
     "Local Work":180, 
     "Remote Failures":0, 
     "Network Blocks":17, 
     "Total MH":0.0000, 
     "Work Utility":0.00, 
     "Difficulty Accepted":0.00000000, 
     "Difficulty Rejected":0.00000000, 
     "Difficulty Stale":0.00000000, 
     "Best Share":0 
    } 
    ], 
    "id":1 
} 
+3

'バナー[ 'STATUS'] [0] [ '解説']' – 2ps

答えて

2
print banner['STATUS'][0]['Description'] # 0 will tell its the 0th index of the list 

'ステータス' キーは、リストを保持しています。そのリストの第1辞書には「説明」が置かれているため、第1辞書にアクセスするには[0]が必要です。