调用函数来实现文件的修改(abc.txt),并增加上时间,调用的是time模块, 需要注意的是,每个函数一定要用‘’‘ ‘’’ 标注下函数说明
# coding=utf-8 # Author: RyAn Bi import time def ogger(): '''print ending''' time_format ='%Y-%m-%d-%X' time_current = time.strftime(time_format) #显示当前时间 with open('abc.txt','a+') as f: f.write('%s end action '%time_current) def test1(): print('in the test1') ogger() def test2(): print('in the test2') ogger() def test3(): print('in the test3') ogger() test1() test2() test3()