configparser操作配置文件
生活随笔
收集整理的這篇文章主要介紹了
configparser操作配置文件
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
import configparser
conf = configparser.ConfigParser()
file_path = "E:\optimize_allchips\config\local.ini"
print(conf.read(file_path, encoding='utf8'))
print(conf.sections()) # 讀取配置文件截點
print(conf.options('RegisterElement')) # 讀取截點下的內容
print(conf.items('RegisterElement')) # 讀取截點下內容所有的鍵值對
print(conf.get('RegisterElement', 'home_login')) # 讀取截點下的指定內容
conf = configparser.ConfigParser()
file_path = "E:\optimize_allchips\config\local.ini"
print(conf.read(file_path, encoding='utf8'))
print(conf.sections()) # 讀取配置文件截點
print(conf.options('RegisterElement')) # 讀取截點下的內容
print(conf.items('RegisterElement')) # 讀取截點下內容所有的鍵值對
print(conf.get('RegisterElement', 'home_login')) # 讀取截點下的指定內容
轉載于:https://www.cnblogs.com/yancy03/p/10184346.html
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的configparser操作配置文件的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: [LeetCode]LRU Cache有
- 下一篇: 文件读取ini文件另一种读取办法