【发布时间】:2013-08-04 19:33:56
【问题描述】:
完整脚本:
import pprint
def application(environ, start_response):
start_response('200 OK', [('content-type', 'text/html')])
aaa = ['a','b','c']
pprint.pprint(aaa)
如果我要在终端中运行它会是......
>>> import pprint
>>> aaa = ['a','b','c']
>>> pprint.pprint(aaa)
['a', 'b', 'c']
>>>
如您所见,它运行良好。但是通过 wsgi-script 它不起作用。
错误日志:
TypeError: 'NoneType' 对象不可迭代
顺便说一句,“pprint”是 PHP 中的“print_r()”等价物?
【问题讨论】:
-
:-) 苏美尔,你并不像你认为的那样聪明或隐秘。但我确实为风格编辑了很多问题,而这个问题还没有消失。
-
赞成,合理的问题; “将响应作为可迭代返回”模式对于任何习惯使用 CGI、php 的人来说都不是很直观
标签: python python-2.7 python-3.x mod-wsgi wsgi