我想从名为IP.txt的文件中将以下字典列表作为输入,并将其存储在名为lst的变量中:
[{"date":"30-Apr-12","price":583.98},{"date":"1-May-12","price":58}]
我该怎么做?
答案 0 :(得分:3)
import json
with open("IP.txt") as json_file:
Ist= json.load(json_file)
print(Ist)
>>>[{'price': 583.98, 'date': '30-Apr-12'}, {'price': 58, 'date': '1-May-12'}]