其他分享
首页 > 其他分享> > 读取excel用字典存储

读取excel用字典存储

作者:互联网

# 传入二维数组,以第一行作为字典关键字,存储数据
def list_turn_dict(tlist: list):
    key = []
    for i in range(len(tlist)):
        dict_f = {}
        if i == 0:
            key = tlist[i]
        else:
            for j in range(len(key)):
                dict_f[key[j]] = tlist[i][j]
            tlist[i] = dict_f
    for lis in tlist:
        print(lis)

输出结果:

 

标签:读取,list,excel,len,dict,key,lis,tlist,字典
来源: https://www.cnblogs.com/zhbbk/p/16369381.html