python学习,day3:函数式编程

调用函数来实现文件的修改(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\n'%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()

  

posted @ 2019-02-13 17:24  bbgoal  阅读(165)  评论(0编辑  收藏  举报