Python讀取INI(確認你的編譯器中安裝了相應的軟件)配置文件
1.簡介
- read(filename) 讀取ini文件內容
- sections() 以列表形式展示所有的section
- options(section) 展示該section的option
- items(section) 得到該section的所有鍵值對
- get(section,option) 得到section中option的值,返回爲string類型
- getint(section,option) 得到section中option的值,返回int類型,還有相應的getboolean()和getfloat()函數。
2.動態寫入配置文件
- add_section(section) 添加一個新的section
- set(section,option,value) 新增section中的option
3.例子
4.ConfigParser Module
RawConfigParser是最基礎的ini文件讀取類
ConfigParser、SafeConfigParser支持參數解析