Python txt创建追加

直接K代码

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