[英]using for loops with bottle
我目前正在开发基于Python的web应用程序一瓶所以我试图做的是打印的结果为循环我曾尝试以下
#!/usr/bin/python
from bottle import *
@route('/')
def index():
for i in range(10):
return i
但这不起作用,我从开发服务器输出中得到了这个
localhost - - [13/Jan/2017 18:11:38] "GET /request HTTP/1.1" 200 0
localhost - - [13/Jan/2017 18:11:40] "GET /favicon.ico HTTP/1.1" 200 0
所以我试过这个
#!/usr/bin/python
from bottle import *
@route('/')
def index():
sumOfValues=0
for i in range(10):
sumOfValues+=i
return sumOfValues
这也不起作用,我的开发服务器给了我这个
localhost - - [13/Jan/2017 18:15:44] "GET /request HTTP/1.1" 500 746
localhost - - [13/Jan/2017 18:15:46] "GET /favicon.ico HTTP/1.1" 500 750
那么我该怎么做我尝试搜索谷歌但没有回来,提前致谢
函数必须返回字符串 - 所以使用return str(sumOfValues)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.