[英]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.