我的JSON文件看起來是這樣的:提取數據
{"07/01/2015-08/01/2015":
{"ABC": [
["12015618727", "2015-07-29 02:32:01"],
["12024079732", "2015-07-24 13:04:01"],
["12024700142", "2015-07-02 00:00:00"]
]
}
}
我想在python從這裏提取號碼12015618727,12024079732,12024700142。
我寫了這個代碼:
import json
numbers=set()
input_file=open('filename', 'r')
json_decode=json.load(input_file)
for item in json_decode["07/01/2015-08/01/2015"]["ABC"]:
for j in item:
numbers.add(j[0])
print " ".join(str(x) for x in numbers)
但這不打印的數字。
[從Python中的JSON文件解析值]可能的重複(http://stackoverflow.com/questions/2835559/parsing-values-from-a-json-file-in-python) –
SO不是一個代碼寫作服務。請閱讀相關主題,進行嘗試,並在遇到麻煩時提供MVE。 –
另一方面,*是*問答網站。我觀察到這個帖子沒有問題。 S.Pandit,你有具體的問題要問嗎? –