风-fmgao

导航

python读取文件中的字典

import ast


def file_read():
    with open('D:\\pytharm\\jichuyufa\\day2\\pro_cty_con.txt', 'r', encoding='utf8') as f:
        san_dic = ast.literal_eval(f.read())
        return san_dic


dic = file_read()
print(dic)

posted on 2018-05-16 14:24  风-fmgao  阅读(1767)  评论(0编辑  收藏  举报