0

我是 Python 3 的新手。我使用 Python 3.5 的 aiohttp 模块。当我运行我的项目时,出现以下错误

TypeError: an integer is required (got type str) 

堆栈跟踪是:

Traceback (most recent call last):
  File "/home/santi/tesis/tanner/server.py", line 82, in <module>
    srv = loop.run_until_complete(f)
  File "/usr/lib/python3.5/asyncio/base_events.py", line 373, in run_until_complete
    return future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result
    raise self._exception
  File "/usr/lib/python3.5/asyncio/tasks.py", line 240, in _step
    result = coro.send(None)
  File "/usr/lib/python3.5/asyncio/base_events.py", line 949, in create_server
    sock.bind(sa)

代码是:

if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    f = loop.create_server(
        lambda: HttpRequestHandler(debug=False, keep_alive=75),'0.0.0.0','8090')
    srv = loop.run_until_complete(f)
    print('serving on', srv.sockets[0].getsockname())
    try:
        loop.run_forever()
    except KeyboardInterrupt:
        pass
  • 我的代码有什么错误?
  • 我究竟做错了什么?
4

1 回答 1

2

端口号应该是一个整数:

f = loop.create_server(
    lambda: HttpRequestHandler(debug=False, keep_alive=75), '0.0.0.0', 8090)
于 2016-06-26T20:09:38.517 回答