简体   繁体   中英

ConfigParser library not working when using with python3

I am using and importing 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.

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.

Wondering what needs to be done for this program to run with python3?

Edit: While using python 2.7 it is working but with python3, i am getting above mention error.

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

If you are using python 3, this will work, the module was renamed

import configparser config = configparser.RawConfigParser()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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