python_50_函数与函数式编程
import time def logger(): """追加写""" time_format='%Y-%m-%d %X'#年-月-日 小时分钟秒 time_current=time.strftime(time_format) with open('uuu.txt','a+') as f: f.write('%s end action\n'%time_current) def fun1(): """描述函数1功能""" print('in the fun1') logger() def fun2(): """描述函数2功能""" print('in the fun2') logger() fun1() fun2() """ 使用函数的三大优点: 1.代码重用 2.保持一致性 3.可扩展性 """