我正在 python 3 中构建一个烧瓶应用程序。我正在尝试写入输出并响应下载。我所做的就是将 sqlite3 db 内容写入一个 excel 文件,试图发送到客户端进行下载。在创建 excel 文件之前,一切似乎都正常。我无法发送给客户。
@app.route('/download', methods=['GET'])
def export_db():
values = execute("SELECT * from table",[])
wb = Workbook()
ws = wb.active
for item in values.fetchall():
ws.append(item)
wb.save('example.xlsx')
output = make_response(wb)
output.headers["Content-Disposition"] = "attachment; filename=" +
"example.xlsx"
output.headers["Content-type"] = "application/vnd.openxmlformats-
officedocument.spreadsheetml.sheet"
return output
Run Code Online (Sandbox Code Playgroud)
我收到的错误信息是,
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1612,
in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1598,
in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/user/Documents/main.py",
line 218, in export_db
output = make_response(wb) …Run Code Online (Sandbox Code Playgroud) 我正在研究引用,我正在尝试一个程序将rvalue传递给函数作为引用参数,就像这样.
#include<iostream>
using namespace std;
int fun(int &x)
{
return x;
}
int main()
{
cout << fun(10);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
但这不起作用,当我试图通过左值时,它起作用了.
#include<iostream>
using namespace std;
int fun(int &x)
{
return x;
}
int main()
{
int x=10;
cout << fun(x);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
谁能解释我为什么会这样?