简体   繁体   English

需要一个整数

[英]An integer is required

I'm new in Python 3. I use aiohttp module for Python 3.5. 我是Python 3的新手。我将aiohttp模块用于Python 3.5。 When I run my project, I have a following error 运行项目时,出现以下错误

TypeError: an integer is required (got type str) 

The stack-trace is: 堆栈跟踪为:

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)

The code is: 代码是:

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
  • What is the error in my code? 我的代码有什么错误?
  • What am I doing wrong? 我究竟做错了什么?

The port number should be an Integer: 端口号应为整数:

f = loop.create_server(
    lambda: HttpRequestHandler(debug=False, keep_alive=75), '0.0.0.0', 8090)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM