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

时间:2022-01-04 15:49:41

I'm using ConfigParser in Python 2.7 to read from a config file and I'm wondering how to read a value such that it's set to the constant None in Python.

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

Currently, my code is as follows:

目前,我的代码如下:

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

However, this shows up as Test Series Parameter = "None" (as a string).

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

1 个解决方案

#1


13  

According to the 2.7.2 docs:

根据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?

当allow_no_value为true(默认值:False)时,接受不带值的选项;为这些提供的值是无。这有帮助吗?

#1


13  

According to the 2.7.2 docs:

根据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?

当allow_no_value为true(默认值:False)时,接受不带值的选项;为这些提供的值是无。这有帮助吗?