0
嘿,我正在運行這段代碼,當我在「/ d」上啓動它時,我希望它打印出整個數據庫,此刻它只打印一行並進行更改到下一個對象,如果我刷新頁面,你能幫忙嗎?從MongoDB打印出多條線
from flask import Flask,render_template
import pymongo
from pymongo import MongoClient
client = MongoClient()
db = client.fliDb
app = Flask(__name__)
games = db.games
g= games.find()
@app.route('/d', methods = ["GET","POST"])
def content():
for game in g:
str(game)
return str(game)
看起來像你的return語句在循環中。只要返回被調用,它完成該功能。 –