zoukankan      html  css  js  c++  java
  • Python-函数

    面向对象编程:华山派----------类  class

    面向过程编程:少林派----------过程     def定义,没有返回值

    函数式编程:峨眉派-------------函数     def定义,有返回值

    在Python中,过程也被当作函数对待,返回值为null

      1:类似打印日志  

    import time    ####导入time的时间包
    time_format='%Y-%m-%d %X' ####定义时间类型
    time_current=time.strftime(time_format) ####得到当前的时间
    def printlog(): ###定义追加写日志的函数
    with open("log.txt",'a+') as f :
    f.write("%s end action " %time_current)
    def test1():
    print ("in the test1")
    printlog()
    def test2():
    print ("in the test2")
    printlog()
    def test3():
    print ("in the test3")
    printlog()
    test1()
    test2()
    test3()

         

  • 相关阅读:
    NSString拼接字符串
    2020/4/26
    2020/4/25
    2020/4/24
    2020/4/22
    2020/4/22
    2020/4/20
    2020/4/19
    2020/4/18
    2020/4/17
  • 原文地址:https://www.cnblogs.com/yujianadu/p/10565138.html
Copyright © 2011-2022 走看看