python配置文件
1 | [top] |
引入库
1 | import configparser |
初始化并读取文件
1 | config = ConfigParser() |
获取所有sections,选择一个section
1 | sections = config.sections() |
获取一个section中的所有键(key)
1 | config.options(sec) |
获取一个section中的所有键值对(key:value)
1 | config.items(sec) |
获取section中某个键的值
1 | config.get(sec, 'categories') |
All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.
Comment
GitalkValine