Python 如何使用mod_wsgi和瓶子在web浏览器中输出int类型?
对于字符串,它是输出的Python 如何使用mod_wsgi和瓶子在web浏览器中输出int类型?,python,bottle,Python,Bottle,对于字符串,它是输出的 from bottle import route @route('/') def index(): return '4' 如果是int,则不输出 from bottle import route @route('/') def index(): return '4' ・为什么? from bottle import route @route('/') def index(): return 4 环境 from bottle impo
from bottle import route
@route('/')
def index():
return '4'
如果是int,则不输出
from bottle import route
@route('/')
def index():
return '4'
・为什么?
from bottle import route
@route('/')
def index():
return 4
环境
from bottle import route
@route('/')
def index():
return '4'
・Python 3.6
・博特尔0.13
・Chrome代码没有问题
from bottle import route
@route('/')
def index():
return '4'
@route('/')
def index2():
return 4
print("type of ", index()," is ", type(index()))
print("type of ", index2()," is ", type(index2()))
我得到的结果是:
type of 4 is <class 'str'>
type of 4 is <class 'int'>
4的类型是
类型4是
FWIW,HTTP请求无论如何都不能返回“int”;HTTP响应是纯文本的。我不知道瓶子是否丢弃非字符串返回类型,或者是否有其他原因…@NeverTrouble。我更改了标题。int也会显示在web浏览器中吗?很抱歉,这可能不起作用。因为“int”对象不可编辑