版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/weixin_40313634/article/details/100862296
问题代码:中文可能乱码
代码语言:javascript复制logging.basicConfig(
filename ='run.log',
filemode = 'w',
datefmt = '%d-%m-%Y %H%M%S',
format = '%(asctime)s %(name)s: %(levelname)s: %(message)s',
level = logging.INFO
)
修正后
代码语言:javascript复制file = open('run.log', encoding="utf-8", mode="w")
logging.basicConfig(
stream=file,
datefmt = '%d-%m-%Y %H%M%S',
format = '%(asctime)s %(name)s: %(levelname)s: %(message)s',
level = logging.INFO
)
参考