- 论坛徽章:
- 0
|
本帖最后由 ulmer 于 2017-09-11 19:41 编辑
Make your data [..][..].. as valid json data structure like: [ [..], .., [..] ]
Put(or read from a file) them into a variable, which you will get full valid json data.
You can access this json's variable to do what you want!
Sample:
test_data_file.json:
- [
- [{"status":2,"mobile":13912345678,"updatetime":"2016-08-29 09:34:07"},{"status":2,"mobile":13912345678,"updatetime":"2016-08-17 12:18:10"},{"status":5,"mobile":13912345678,"updatetime":"2016-08-17 12:14:09"},{"status":4,"mobile":13912345678,"updatetime":"2016-08-17 12:05:23"}],
- [{"status":2,"mobile":13312345678,"updatetime":"2016-05-15 22:07:33"}],
- [{"status":1,"mobile":17712345678,"updatetime":"2016-02-29 09:34:07"},{"status":5,"mobile":17712345678,"updatetime":"2016-08-17 12:14:09"},{"status":5,"mobile":17712345678,"updatetime":"2016-08-17 12:05:23"}],
- [{"status":3,"mobile":15512345678,"updatetime":"2016-02-29 09:34:07"},{"status":1,"mobile":15512345678,"updatetime":"2016-08-17 12:05:23"}]
- ]
复制代码
test.py:
- import json
- file_path = './test_data_file.json'
- data_records = [];
- with open (file_path) as json_data:
- data_records = json.load(json_data)
- # call all updatetime's value in the first data record:
- print(data_records[0][0]['updatetime'])
复制代码
|
|