【发布时间】:2019-11-25 12:35:16
【问题描述】:
我在开发需要使用 while 语句的烧瓶代码应用程序时遇到问题。根据这段代码,我想根据“x”和“i”值重复返回。该应用程序运行正确,但它只返回第一个值(我相信不会返回到 while 语句,因为“i”没有改变它的值)。代码如下:
from flask import Flask
app = Flask(__name__) #create the Flask app
app.secret_key = "hello"
@app.route('/begin') #allow both GET and POST requests
def form():
x = 4
i = 1
while i <= x:
return '''The value is : '''+str(i)+'''\n'''
i += 1
else:
return '''done.'''
pass
if __name__ == '__main__':
app.config['SESSION_TYPE'] = 'filesystem'
app.run(debug=True, port=5000)
【问题讨论】: