0
返回config.read()我有一個config.py讀取多個配置文件。從函數
from ConfigParser import *
def zones_config():
zones_config = ConfigParser()
zones = zones_config.sections()
zones_config.read('zones.ini'), zones
def settings_config():
settings_config = ConfigParser()
settings_config.read('settings.ini')
然後在我的database.py文件:
from utils.config import settings_config
settings_config()
#mysqbdb config
ip = settings_config.get('mysqldb', 'ip')
username = settings_config.get('mysqldb', 'username')
password = settings_config.get('mysqldb', 'password')
database = settings_config.get('mysqldb', 'database')
不過,我得到以下錯誤:
AttributeError: 'function' object has no attribute 'get'