Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/316.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何使用mod_wsgi和瓶子在web浏览器中输出int类型?_Python_Bottle - Fatal编程技术网

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”对象不可编辑