config.read('example.ini',encoding="utf-8")
"""讀取配置文件,python3可以不加encoding"""
options(section)
"""sections(): 得到所有的section,并以列表的形式返回"""
config.defaults()
"""defaults():返回一個包含實例范圍默認值的詞典"""
config.add_section(section)
"""添加一個新的section"""
config.has_section(section)
"""判斷是否有section"""
print(config.options(section))
"""得到該section的所有option"""
has_option(section, option)
"""判斷如果section和option都存在則返回True否則False"""
read_file(f, source=None)
"""讀取配置文件內容,f必須是unicode"""
read_string(string, source=’’)
"""從字符串解析配置數(shù)據(jù)"""
read_dict(dictionary, source=’’)
"""從詞典解析配置數(shù)據(jù)"""
get(section, option, *, raw=False, vars=None[, fallback])
"""得到section中option的值,返回為string類型"""
getint(section,option)
"""得到section中option的值,返回為int類型"""
getfloat(section,option)
"""得到section中option的值,返回為float類型"""
getboolean(section, option)
"""得到section中option的值,返回為boolean類型"""
items(raw=False, vars=None)
"""和items(section, raw=False, vars=None):列出選項的名稱和值"""
set(section, option, value)
"""對section中的option進行設置"""
write(fileobject, space_around_delimiters=True)
"""將內容寫入配置文件。"""
remove_option(section, option)
"""從指定section移除option"""
remove_section(section)
"""移除section"""
optionxform(option)
"""將輸入文件中,或客戶端代碼傳遞的option名轉化成內部結構使用的形式。默認實現(xiàn)返回option的小寫形式;"""
readfp(fp, filename=None)
"""從文件fp中解析數(shù)據(jù)"""