读取两个txt文档,生产一个键值对

# -*- coding:utf-8 -*-
# 生产键列表
f = open(r'key_list.txt', 'r')
a = [i.replace('\n', '') for i in f]
# 生成值列表
f2 = open(r'value_list.txt', 'r')
b = [i.replace('\n', '') for i in f2]
# 转变成键值对
dict_list = dict(zip(a, b))
print(dict_list)

 

posted @ 2023-05-30 16:14  布都御魂  阅读(6)  评论(0编辑  收藏  举报