在Flask中,我可以执行以下操作:
app.config.from_object(config)
app.config.from_pyfile('settings.cfg', silent=True)
app.config.from_object(settings_override)
如果没有“ settings.cfg”文件,则该应用将使用“ config”对象。如果存在“ settings.cfg”,则其中的任何设置都将覆盖“ config”对象。
如何使用ConfigParser模块实现相同的目的?谢谢