def writeTxt(path,message): with open(path,‘a‘) as f: # a是追加,如果不存在则创建文件 f.write(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())+"\t"+message+‘\n‘) #当前时间加上 输出消息
Python txt创建追加
原文:https://www.cnblogs.com/Alex-Mercer/p/12723572.html