簡體   English   中英

與 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中已重命名為configparser

如果您使用的是 python 3,這將起作用,模塊已重命名

導入 configparser config = configparser.RawConfigParser()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM