![](/img/trans.png)
[英]TypeError: __init__() got an unexpected keyword argument 'log_dir'
[英]TypeError: _log() got an unexpected keyword argument 'stacklevel'
將 stacklevel 與 log.error 一起使用會產生此錯誤。 前任:
logger = logging.getLogger('tcpserver')
logger.error("Connection problem", stack_info=sys.exc_info(), stacklevel=1)
而根據文檔: kwargs 中有四個關鍵字參數被檢查:exc_info、stack_info、stacklevel 和 extra。
請參閱https://docs.python.org/3/library/logging.html#logging.Logger.debug
您正在查看的文檔與解釋器的版本不匹配。 它也很好地記錄在案: https : //docs.python.org/3.8/library/logging.html#logging.Logger.debug
在 3.8 版更改: 添加了 stacklevel 參數。
要么升級你的解釋器,要么使用匹配的文檔,例如: https : //docs.python.org/3.7/library/logging.html#logging.Logger.debug (通常不要忘記檢查底部的 API 更改說明很有用,也為了與其他可能的用戶及其環境兼容)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.