python - 如何使用 ConfigParser 将值设置为 None?

标签 python configparser

我在 Python 2.7 中使用 ConfigParser 来读取配置文件,我想知道如何读取一个值,以便在 Python 中将其设置为常量 None

目前我的代码如下:

config.set("Test Series Parameters", "Test Series Parameter", None)

但是,这显示为 Test Series Parameter = "None"(作为字符串)。

最佳答案

根据 2.7.2 文档:

When allow_no_value is true (default: False), options without values are accepted; the value presented for these is None. Does that help?

关于python - 如何使用 ConfigParser 将值设置为 None?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9335885/

相关文章:

python - 在小于 O(n) 的时间内找到小于给定数字的斐波那契和

python - 从网络导入模块

python - 如何使用 ConfigParser 处理配置文件中的空值?

python - 如何为 SafeConfigParser 设置默认值?

python - 关闭由 ConfigParser 打开的文件

python - 使用 Python mechanize 通过登录屏幕

python - 如果值相同,则合并 pandas 数据框单元格

python - SafeConfigParser.read() 使用文件对象而不是字符串

Python:Configparser - 转义换行符?

python - 如何在 Python 中查找 base64 编码图像的文件扩展名