• python第二十天


    python第二十天

    shutil模块

    import shutil
    
    # shutil.copy2('D:python_22day21lianjia.html',#
    #              'D:python_22day21lianjia_bk.html')
    
    # shutil.copytree("outer",
    #                 "outer3",
    #                 ignore=shutil.ignore_patterns("__init__.py","sag"))
    
    # shutil.rmtree("D:python_22day21outer3")
    
    # shutil.move("D:python_22day21day20_bak","D:python_22day20", copy_function=shutil.copy2)
    
    # total, used, free = shutil.disk_usage("c:\")
    # print("当前磁盘共: %iGB, 已使用: %iGB, 剩余: %iGB"%(total / 1073741824, used / 1073741824, free / 1073741824))
    
    # shutil.make_archive('outer_z', 'zip','D:python_22day21outer')
    
    # shutil.unpack_archive('outer_z.zip',r'D:python_22day21unzip')
    

    logging模块

    # 同时向文件和屏幕上输出 和 乱码
    # fh = logging.FileHandler('tmp.log',encoding='utf-8')
    # # fh2 = logging.FileHandler('tmp2.log',encoding='utf-8')
    # sh = logging.StreamHandler()
    # logging.basicConfig(
    #     format='%(asctime)s - %(name)s - %(levelname)s[line :%(lineno)d]-%(module)s:  %(message)s',
    #     datefmt='%Y-%m-%d %H:%M:%S %p',
    #     level= logging.DEBUG,
    #     # handlers=[fh,sh,fh2]
    #     handlers=[fh,sh]
    # )
    # logging.debug('debug 信息错误 test2')
    # logging.info('warning 信息错误 test2')
    # logging.warning('warning message test2')
    # logging.error('error message test2')
    # logging.critical('critical message test2')
    
    # 做日志的切分
    # import time
    # from logging import handlers
    # sh = logging.StreamHandler()
    # rh = handlers.RotatingFileHandler('myapp.log', maxBytes=1024,backupCount=5)   # 按照大小做切割
    # fh = handlers.TimedRotatingFileHandler(filename='x2.log', when='s', interval=5, encoding='utf-8')
    # logging.basicConfig(
    #     format='%(asctime)s - %(name)s - %(levelname)s[line :%(lineno)d]-%(module)s:  %(message)s',
    #     datefmt='%Y-%m-%d %H:%M:%S %p',
    #     level= logging.DEBUG,
    #     # handlers=[fh,sh,fh2]
    #     handlers=[fh,rh,sh]
    # )
    # for i in range(1,100000):
    #     time.sleep(1)
    #     logging.error('KeyboardInterrupt error %s'%str(i))
    
  • 相关阅读:
    史上最全设计模式导学目录(完整版)
    代码整洁之道读后感(三)
    代码整洁之道读后感(二)
    代码整洁之道读后感(一)
    groovy的三个强劲属性(一)Gpath
    spring mvc 自定义编辑器
    Class.this 和 this 的有什么不同
    python 异常知识点
    Freemaker 自定义指令和函数
    Freemaker如何遍历key为non-string类型的map?
  • 原文地址:https://www.cnblogs.com/styxr/p/12184567.html
Copyright © 2020-2023  润新知