2017-01-13 6 views
-3

Ich habe eine txt-Datei analysieren: resultJSON.txtwie json.txt lesen und json python READ TXT PYTHON

die Daten in der txt-Datei ist im JSON-Format.

{ 
    "term": "dog", 
    "results": [{ 
     "filename": "1.jpg", 
     "numberID": "D12" 
    }, { 
     "filename": "23.jpg", 
     "number": "E52" 
    }] 
} 

Ich möchte die txt in Python lesen und die JSON zu analysieren.

Wie liest man den TXT ???

+2

Mögliche Duplikate von [JSON in Python parsen] (http://stackoverflow.com/questions/7771011/parse-json-in-python) –

+0

Mögliches Duplikat von [Parsen von Werten aus einer JSON-Datei?] (Http://stackoverflow.com/questions/2835559/parsing-values-from-a-json-file) – iFlo

+0

OH BITTE LESEN SIE TXT, nicht dupliziert – HiPownedBi

Antwort

1

Sicherstellen, dass der folgende Code ist in dem gleichen Ordner wie resultJSON.txt:

import json 
with open('resultJSON.txt') as f: 
    json_data = json.load(f) 

Ihre Daten in json_data sein wird.

+0

vielen dank ..... – HiPownedBi