使用python做后台接口出现的问题

出现的问题:TypeError: write() only accepts bytes, unicode, and dict objects. Lists not accepted for security reasons; see http://www.tornadoweb.org/en/stable/web.html#tornado.web.RequestHandler.w rite

这是因为python不支持返回list列表,需要以

  write能写的几种格式    bytes, unicode, and dict objects
    bytes
    字符串
    字典
    json
    flush
    渲染模板render  添加模板位置templates
    路由跳转redirect
    结束:finish

形式返回数据,才不会报错

猜你喜欢

转载自www.cnblogs.com/lxz123/p/13186090.html