python3.configparser用法

'''
https://www.cnblogs.com/xiazhenyu/
*** 学而思之、思而记之、记而习之 ***
'''
# coding=utf-8
# 注意:在 Python 3.x 版本后,ConfigParser.py 已经更名为 configparser.py
import configparser
cf = configparser.ConfigParser()
cf.read('dict_file.txt')
assetids = cf.get('dict', "user") #获取 'dict_file.txt' 文件中 user对应的值
print(type(assetids),assetids)# 打印结果:<class 'str'> lalala
# 文件内容:
'''
[dict]
user=lalala
'''
posted @ 2020-09-24 23:54  sunny.boy  阅读(481)  评论(0编辑  收藏  举报