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())+"\t"+message+'\n')  #当前时间加上 输出消息
posted @ 2020-04-18 00:21  Alex_Mercer  阅读(143)  评论(0编辑  收藏  举报