[英]Syntax error flask application
我有以下代码:
t1 = threading.Thread(target = app.run, args = (host='0.0.0.0', port = 443))
它给了我一个错误:
File "/home/deploy/tgbot/tgbot.py", line 1170
t1 = threading.Thread(target = app.run, args = (host='0.0.0.0', port = 443))
^
问题是什么?
app.run
的顺序参数可以在元组中传递(用括号构造,但没有名称)。 命名参数必须在字典中传递。 字典使用dict()
或大括号(而不是括号dict()
构造。
由于host
和port
是app.run
的前两个参数,因此以下任何一项都可以工作:
# positional args, passed as a tuple
t1 = threading.Thread(target=app.run, args=('0.0.0.0', 443))
# named args, passed in a dictionary created via dict()
t1 = threading.Thread(target=app.run, kwargs=dict(host='0.0.0.0', port=443))
# named args, passed in a dictionary created via {}
t1 = threading.Thread(target=app.run, kwargs={'host': '0.0.0.0', 'port': 443}))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.