python 读写ini文件


前言

今天给大家介绍一下,用python怎么快速读写ini配置文件


python 读写ini文件_第1张图片

一、python读文件

import configparser
cfp = configparser.ConfigParser()
cfp.read("test.ini")

'''获取所有的selections'''
selections = cfp.sections()
print(selections) #  ['Title1', 'Title2']

'''获取指定selections下的所有options'''
options = cfp.options("Title1")
print(options)  # ['key1', 'key2']

'''获取指定selection下的指定option的值'''
value= cfp.get("Title1", 

你可能感兴趣的:(pyqt5,python,开发语言)