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
python、aiohttp、AssertionError:数据参数必须是带字节的(<;class';str';>;)_Python_Heroku_Aiohttp - Fatal编程技术网

python、aiohttp、AssertionError:数据参数必须是带字节的(<;class';str';>;)

python、aiohttp、AssertionError:数据参数必须是带字节的(<;class';str';>;),python,heroku,aiohttp,Python,Heroku,Aiohttp,我得到了标题中显示的错误。以下是回溯: 2020-01-13T05:03:49.967604+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/aiohttp_debugtoolbar/middlewares.py", line 57, in toolbar_middleware 2020-01-13T05:03:49.967606+00:00 app[web.1]: return (yie

我得到了标题中显示的错误。以下是回溯:

2020-01-13T05:03:49.967604+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/aiohttp_debugtoolbar/middlewares.py", line 57, in toolbar_middleware
2020-01-13T05:03:49.967606+00:00 app[web.1]:     return (yield from handler(request))
2020-01-13T05:03:49.967608+00:00 app[web.1]:   File "/app/handlers/utils/web.py", line 139, in inner
2020-01-13T05:03:49.967610+00:00 app[web.1]:     return await func(request, prepare_response, filepath, **func_kwargs)
2020-01-13T05:03:49.967612+00:00 app[web.1]:   File "/app/handlers/csv2html.py", line 37, in csv2html
2020-01-13T05:03:49.967614+00:00 app[web.1]:     await response.write(reader.to_html())
2020-01-13T05:03:49.967616+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/aiohttp/web_response.py", line 416, in write
2020-01-13T05:03:49.967618+00:00 app[web.1]:     "data argument must be byte-ish (%r)" % type(data)
2020-01-13T05:03:49.967620+00:00 app[web.1]: AssertionError: data argument must be byte-ish (<class 'str'>)
Disconnected from log stream. There may be events happening that you do not see here! Attempting to reconnect...
2020-01-13T05:03:49.967602+00:00 app[web.1]:     response = await handler(request)
2020-01-13T05:03:49.967604+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/aiohttp_debugtoolbar/middlewares.py", line 57, in toolbar_middleware
2020-01-13T05:03:49.967606+00:00 app[web.1]:     return (yield from handler(request))
2020-01-13T05:03:49.967608+00:00 app[web.1]:   File "/app/handlers/utils/web.py", line 139, in inner
2020-01-13T05:03:49.967610+00:00 app[web.1]:     return await func(request, prepare_response, filepath, **func_kwargs)
2020-01-13T05:03:49.967612+00:00 app[web.1]:   File "/app/handlers/csv2html.py", line 37, in csv2html
2020-01-13T05:03:49.967614+00:00 app[web.1]:     await response.write(reader.to_html())
2020-01-13T05:03:49.967616+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/aiohttp/web_response.py", line 416, in write
2020-01-13T05:03:49.967618+00:00 app[web.1]:     "data argument must be byte-ish (%r)" % type(data)
2020-01-13T05:03:49.967620+00:00 app[web.1]: AssertionError: data argument must be byte-ish (<class 'str'>)
2020-01-13T05:03:49.967604+00:00应用程序[web.1]:文件“/app/.heroku/python/lib/python3.6/site packages/aiohttp_debugtoolbar/middleware.py”,第57行,在toolbar_中间件中
2020-01-13T05:03:49.967606+00:00应用程序[web.1]:返回(处理程序的收益(请求))
2020-01-13T05:03:49.967608+00:00应用程序[web.1]:文件“/app/handlers/utils/web.py”,第139行,在内部
2020-01-13T05:03:49.967610+00:00应用程序[web.1]:返回等待函数(请求、准备响应、文件路径,**函数)
2020-01-13T05:03:49.967612+00:00应用程序[web.1]:文件“/app/handlers/csv2html.py”,第37行,在csv2html中
2020-01-13T05:03:49.967614+00:00应用程序[web.1]:等待响应。写入(reader.to_html())
2020-01-13T05:03:49.967616+00:00应用程序[web.1]:文件“/app/.heroku/python/lib/python3.6/site packages/aiohttp/web_response.py”,第416行,以书面形式
2020-01-13T05:03:49.967618+00:00应用程序[web.1]:“数据参数必须是字节(%r)”%type(数据)
2020-01-13T05:03:49.967620+00:00应用程序[web.1]:AssertionError:数据参数必须为byte ish()
已断开与日志流的连接。可能会发生您在此处看不到的事件!正在尝试重新连接。。。
2020-01-13T05:03:49.967602+00:00应用程序[web.1]:响应=等待处理程序(请求)
2020-01-13T05:03:49.967604+00:00应用程序[web.1]:文件“/app/.heroku/python/lib/python3.6/site packages/aiohttp\u debugtoolbar/middleware.py”,第57行,在toolbar\u中间件中
2020-01-13T05:03:49.967606+00:00应用程序[web.1]:返回(处理程序的收益(请求))
2020-01-13T05:03:49.967608+00:00应用程序[web.1]:文件“/app/handlers/utils/web.py”,第139行,在内部
2020-01-13T05:03:49.967610+00:00应用程序[web.1]:返回等待函数(请求、准备响应、文件路径,**函数)
2020-01-13T05:03:49.967612+00:00应用程序[web.1]:文件“/app/handlers/csv2html.py”,第37行,在csv2html中
2020-01-13T05:03:49.967614+00:00应用程序[web.1]:等待响应。写入(reader.to_html())
2020-01-13T05:03:49.967616+00:00应用程序[web.1]:文件“/app/.heroku/python/lib/python3.6/site packages/aiohttp/web_response.py”,第416行,以书面形式
2020-01-13T05:03:49.967618+00:00应用程序[web.1]:“数据参数必须是字节(%r)”%type(数据)
2020-01-13T05:03:49.967620+00:00应用程序[web.1]:AssertionError:数据参数必须为byte ish()
该应用程序是另一个应用程序的api。它使用aiohttp,托管在heroku。被调用的这个特定函数应该将csv转换为html


如果您愿意,我可以显示更多代码,但我认为不需要这样做。如果我错了,请纠正我。有人能帮忙吗?提前感谢。

/app/handlers/csv2html.py的
37行中
替换
等待响应。write(reader.to_html())
等待响应。write(reader.to_html().encode(“utf-8”)