Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
使用会在烧瓶中app.open_resource('foobar.txt', 'w')生成错误。Resources can only be opened for reading
app.open_resource('foobar.txt', 'w')
Resources can only be opened for reading
有没有办法打开一个资源来写入它?
如果没有,您能否使用烧瓶获取资源的路径,然后我可以手动打开它并写入它。
这应该有效:
import os f = open(os.path.join(app.root_path, 'foobar.txt'), 'w')
这更方便:
import os with open(os.path.join(app.root_path, 'foobar.txt'), 'w') as f: ...