python读取字典类型的文本文件

比如D盘有个txt 文本文件TestConf.ini,它的内容是一个字典:{"tester":"sterson","projectName":"baidu"}

 

def read_test_conf(conf_path):
    f=open(conf_path,"r")
    test_config=eval(f.read())
    f.close()
    return test_config
#读取配置文件
test_config=read_test_conf('d:\\TestConf.ini')

#读取projectName

 

proName=test_config["projectName"]  #就是baidu

 

你可能感兴趣的:(python)