config.read(
'example.ini'
,encoding
=
"utf-8"
)
"""讀取配置文件,python3可以不加encoding"""
options(section)
"""sections(): 得到所有的section,并以列表的形式返回"""
config.defaults()
"""defaults():返回一個(gè)包含實(shí)例范圍默認(rèn)值的詞典"""
config.add_section(section)
"""添加一個(gè)新的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
)
"""讀取配置文件內(nèi)容,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類(lèi)型"""
getint(section,option)
"""得到section中option的值,返回為int類(lèi)型"""
getfloat(section,option)
"""得到section中option的值,返回為float類(lèi)型"""
getboolean(section, option)
"""得到section中option的值,返回為boolean類(lèi)型"""
items(raw
=
False
,
vars
=
None
)
"""和items(section, raw=False, vars=None):列出選項(xiàng)的名稱(chēng)和值"""
set
(section, option, value)
"""對(duì)section中的option進(jìn)行設(shè)置"""
write(fileobject, space_around_delimiters
=
True
)
"""將內(nèi)容寫(xiě)入配置文件。"""
remove_option(section, option)
"""從指定section移除option"""
remove_section(section)
"""移除section"""
optionxform(option)
"""將輸入文件中,或客戶(hù)端代碼傳遞的option名轉(zhuǎn)化成內(nèi)部結(jié)構(gòu)使用的形式。默認(rèn)實(shí)現(xiàn)返回option的小寫(xiě)形式;"""
readfp(fp, filename
=
None
)
"""從文件fp中解析數(shù)據(jù)"""