【Python 数据结构】 微复杂数据结构的渲染

data = [
    {
        "Monday": [{
            "08:00": "Test",
            "09:00": "Test",
            "10:00": "Test",
            "11:00": "Test",
        }],
    },
    {
        "Tuesday": [{
            "08:00": "Test",
            "09:00": "Test",
            "10:00": "Test",
            "11:00": "Test",
        }],
    }
]

for obj in data:
    print("当前对象", obj.keys())
    for week in list(obj.keys()):
        print(obj[week])
        for time in obj[week]:
            print(time.keys())
            print(time.values())





# 输出
  当前对象 dict_keys(['Monday'])
  [{'08:00': 'Test', '09:00': 'Test', '10:00': 'Test', '11:00': 'Test'}]
  dict_keys(['08:00', '09:00', '10:00', '11:00'])
  dict_values(['Test', 'Test', 'Test', 'Test'])

  当前对象 dict_keys([
'Tuesday'])   [{'08:00': 'Test', '09:00': 'Test', '10:00': 'Test', '11:00': 'Test'}]   dict_keys(['08:00', '09:00', '10:00', '11:00'])   dict_values(['Test', 'Test', 'Test', 'Test'])

 

posted @ 2020-11-07 20:55  PythonNew_Mr.Wang  Views(73)  Comments(0Edit  收藏  举报