如何使用configparser模块在Python中高效读写配置文件?
- 内容介绍
- 文章标签
- 相关推荐
本文共计2130个文字,预计阅读时间需要9分钟。
简介+编写一个登录注册的demo,但之前的demo数据都写在程序里面,每次删除程序数据就丢失了。+想写到配置文件里好了+Python本身提供了一个Module- config parser,来进行配置
简介
想写一个登录注册的demo,但是以前的demo数据都写在程序里面,每一关掉程序数据就没保存住。。
于是想着写到配置文件里好了
Python自身提供了一个Module - configparser,来进行对配置文件的读写
Configuration file parser.
A configuration file consists of sections, lead by a “[section]” header,
and followed by “name: value” entries, with continuations and such in
the style of RFC 822.
Note The ConfigParser module has been renamed to configparser in Python 3. The 2to3 tool will automatically adapt imports when converting your sources to Python 3.
在py2中,该模块叫ConfigParser,在py3中把字母全变成了小写。
本文共计2130个文字,预计阅读时间需要9分钟。
简介+编写一个登录注册的demo,但之前的demo数据都写在程序里面,每次删除程序数据就丢失了。+想写到配置文件里好了+Python本身提供了一个Module- config parser,来进行配置
简介
想写一个登录注册的demo,但是以前的demo数据都写在程序里面,每一关掉程序数据就没保存住。。
于是想着写到配置文件里好了
Python自身提供了一个Module - configparser,来进行对配置文件的读写
Configuration file parser.
A configuration file consists of sections, lead by a “[section]” header,
and followed by “name: value” entries, with continuations and such in
the style of RFC 822.
Note The ConfigParser module has been renamed to configparser in Python 3. The 2to3 tool will automatically adapt imports when converting your sources to Python 3.
在py2中,该模块叫ConfigParser,在py3中把字母全变成了小写。

