在阅读flask api文档时,我遇到了这个打开文件的open_resource方法,就像这样
with app.open_resource('schema.sql') as f:
contents = f.read()
do_something_with(contents)
Run Code Online (Sandbox Code Playgroud)
但为什么不这样做呢?
with open('schema.sql') as f:
contents = f.read()
do_something_with(contents)
Run Code Online (Sandbox Code Playgroud)
我想看到一个用例,其中 app.open_resource 可以做一些 open 不能做的事情