Python讀取INI配置文件

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支持參數解析

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章