[英]Hide console using structlog
structlog 可以与pythonw一起使用以仅登录文件吗?
当使用 pythonw 运行 python 代码时,导入 structlog 失败,因为sys.stdout
是None
。
调用sys.stdout.isatty()
时,文件structlog/_config.py
中会出现错误。
这是一个揭示问题的简单测试。
# python try_import_structlog.pyw --> success
# pythonw try_import_structlog.pyw --> fail
with open("result.txt", "a") as file:
try:
import structlog
except Exception as error:
file.write(f"import failed: {error}")
else:
file.write("import succeeded")
这是 structlog 中的一个错误,将在下一个版本中修复。 我想它可能会在这个周末发布。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.