为什么要使用flask open_resource [英] Why use flask open_resource
本文介绍了为什么要使用flask open_resource的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在阅读flask api文档时,我遇到了这样的open_resource方法,该方法打开文件
while reading flask api documentation, I came across this open_resource method that opens file, like this
with app.open_resource('schema.sql') as f:
contents = f.read()
do_something_with(contents)
但是为什么不这样做呢?
but why not just do this?
with open('schema.sql') as f:
contents = f.read()
do_something_with(contents)
我想看看一个用例,其中app.open_resource可以执行open尚未执行的操作
I want to see a use case where app.open_resource could do something that open can't already do
推荐答案
查看全文