我是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
答案 0 :(得分:2)
端口号应为整数:
f = loop.create_server(
lambda: HttpRequestHandler(debug=False, keep_alive=75), '0.0.0.0', 8090)