小编Bra*_*phy的帖子

python如何从列表中创建字典中的字典

我有一个文件名列表,examples = ['f1','f2','f3','f4'],一天中的时间,t = ['am','pm']以及收集的数据类型, [ '温度', '湿度'].

从这些我想以下列格式在字典中创建字典:

dict = {'f1': { am : {'temp': [], 'humidity': []} , pm : {'temp': [], 'humidity': []}},
        'f2': { am : {'temp': [], 'humidity': []} , pm : {'temp': [], 'humidity': []}},
        'f3': { am : {'temp': [], 'humidity': []} , pm : {'temp': [], 'humidity': []}},
        'f4': { am : {'temp': [], 'humidity': []} , pm : {'temp': [], 'humidity': []}}}
Run Code Online (Sandbox Code Playgroud)

最好的方法是什么?非常感谢先进.

python list dictionary-comprehension

0
推荐指数
1
解决办法
176
查看次数

标签 统计

dictionary-comprehension ×1

list ×1

python ×1