zoukankan      html  css  js  c++  java
  • 函数作用域及简单模块

    python函数的作用域分四种情况:
    L E G B

    • ---------L: local,局部作用域,即函数中定义的变量;
    • ---------E:enclosing,嵌套的父级函数的局部作用域,即包含此函数的上级函数的局部作用域,但不是全局的;
    • ---------G:global,全局变量,就是模块级别定义的变量;
    • ---------B:built-in,系统固定模块里面的变量,比如int,bytearray等。搜索变量的优先级顺序依次是:作用域局部>外层作用域>当前模块中的全局>python内置作用域

     时间模块:time

    import time
    struct_time=time.localtime()                                     当地的时间
    print(time.strftime('%Y——%m——%d %H:%M:%S,struct_time))           打印出年月日,时分秒            自定制
    
    import datetime
    print(datetime.datetime.now())                                   打印当前时间
  • 相关阅读:
    array_merge
    漏斗模型
    3 破解密码,xshell连接
    2-安装linux7
    1-Linux运维人员要求
    17-[模块]-time&datetime
    16-[模块]-导入方式
    Nginx服务器
    15-作业:员工信息表查询
    14-本章总结
  • 原文地址:https://www.cnblogs.com/ssxblog/p/10626820.html
Copyright © 2011-2022 走看看