与 python3 一起使用时 ConfigParser 库不工作
ConfigParser library not working when using with python3
我正在使用并导入 ConfigParaser
import ConfigParser
config = ConfigParser.RawConfigParser()
config.read('Config.properties')
timeout_val=config.get('Section', 'commandtimeout')
并使用
安装
pip install ConfigParser
虽然 运行 宁 python 脚本出现下面提到的错误。
Traceback (most recent call last):
File "system_offline.py", line 41, in <module>
import ConfigParser
ImportError: No module named 'ConfigParser'
现在,我的问题是,如果 运行 在同一系统上使用 python 2.7 的同一程序,上面的导入语句是否可以正常工作。
想知道这个程序需要做什么才能 运行 和 python3?
编辑:在使用 python 2.7 时可以正常工作,但在使用 python3 时,出现上述错误。
ConfigParser
模块在 Python 3.0 中是 renamed to configparser
。
如果您使用的是 python 3,这将起作用,模块已重命名
导入配置分析器
配置 = configparser.RawConfigParser()
我正在使用并导入 ConfigParaser
import ConfigParser
config = ConfigParser.RawConfigParser()
config.read('Config.properties')
timeout_val=config.get('Section', 'commandtimeout')
并使用
安装pip install ConfigParser
虽然 运行 宁 python 脚本出现下面提到的错误。
Traceback (most recent call last):
File "system_offline.py", line 41, in <module>
import ConfigParser
ImportError: No module named 'ConfigParser'
现在,我的问题是,如果 运行 在同一系统上使用 python 2.7 的同一程序,上面的导入语句是否可以正常工作。
想知道这个程序需要做什么才能 运行 和 python3?
编辑:在使用 python 2.7 时可以正常工作,但在使用 python3 时,出现上述错误。
ConfigParser
模块在 Python 3.0 中是 renamed to configparser
。
如果您使用的是 python 3,这将起作用,模块已重命名
导入配置分析器 配置 = configparser.RawConfigParser()