简体   繁体   English

与 python3 一起使用时,ConfigParser 库不起作用

[英]ConfigParser library not working when using with python3

I am using and importing ConfigParaser我正在使用和导入 ConfigParaser

import ConfigParser
config = ConfigParser.RawConfigParser()
config.read('Config.properties')
timeout_val=config.get('Section', 'commandtimeout') 

and install it using,并使用安装它,

pip install ConfigParser

While running the python script getting below mention error.在运行 python 脚本时,出现以下提到的错误。

Traceback (most recent call last):
  File "system_offline.py", line 41, in <module>
    import ConfigParser
ImportError: No module named 'ConfigParser'

Now, my question is if run the same program using python 2.7 at the same system, above import statement works with out issue.现在,我的问题是,如果在同一个系统上使用 python 2.7 运行同一个程序,上面的导入语句没有问题。

Wondering what needs to be done for this program to run with python3?想知道这个程序需要做什么才能与python3一起运行吗?

Edit: While using python 2.7 it is working but with python3, i am getting above mention error.编辑:虽然使用 python 2.7 它可以工作但使用 python3,我得到上面提到的错误。

ConfigParser模块在Python 3.0中已重命名为configparser

If you are using python 3, this will work, the module was renamed如果您使用的是 python 3,这将起作用,模块已重命名

import configparser config = configparser.RawConfigParser()导入 configparser config = configparser.RawConfigParser()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM