flask from_object和from_pyfile的区别
- from_object接受的是一个模块对象,需求导入
- from_pyfile接受的是一个文件名的字符串,文件可以不是py文件也可以是txt文件
-
from flask import Flask app = Flask(__name__) app.config.from_pyfile('config.py', silent=True) @app.route('/') def hello_world(): return 'Hello World!' if __name__ == '__main__': app.run()
slient = True,当文件的路径不存在时,不会引发异常