我的FlaskAPI返回的数据很难在前端的JS中使用
以下是端点:
class BilagList(Resource):
def get(self):
connection = sqlite3.connect('data.db')
cursor = connection.cursor()
query = "SELECT * FROM bilag"
result = cursor.execute(query)
row = result.fetchall()
return {'bilag': row}
结果如下:
{
"bilag":
[
[1, "description", "price", null],
[2, "2description", "2price", null],
[22, "Her er Serenas f\u00f8rste bilag!", "1000", "Serena"],
[23, "Her er Admins f\u00f8rste bilag!", "1000", "admin"]
]
}
我只想:
[1, "description", "price", null],
[2, "2description", "2price", null],
[22, "Her er Serenas f\u00f8rste bilag!", "1000", "Serena"],
[23, "Her er Admins f\u00f8rste bilag!", "1000", "admin"]
然后我就可以用js在数组中循环
我可以删除 { “比拉格”: }
,只返回第一排,但我如何摆脱最后一对[]? 有什么好的理由不这样做吗
克瑞斯滕酒店
您可以返回
str(row)[1:-1]
,但可以查看here相关问题 更多 >
编程相关推荐