发现有时日志文件不能使用,我简单写了个日志文件储存。
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2021/3/31 下午11:41
# @Author : wangying
# @Site :
# @File : mac自制日志.py
# @Software: PyCharm
import time
def self_log(msg):
print(msg)
write(msg)
pass
def write(msg):
with open('./log.txt', 'a', encoding='utf-8') as f:
f.write(msg)
f.write('\n\f')
if __name__ == '__main__':
while 1:
self_log('日志文件')
time.sleep(1)
本文介绍了如何在Python中为Mac系统创建一个简单的日志文件系统,通过self_log函数记录和写入日志,便于问题排查。
3万+

被折叠的 条评论
为什么被折叠?



