zoukankan      html  css  js  c++  java
  • shutil 模块

    一、引入模块

      import shutil       #高级的 文件、文件夹、压缩包 处理模块

    二、func 介绍

     1 import shutil
     2 
     3 # copy(src, dst);Copy data and mode bits ("cp src dst"). Return the file's destination.
     4 shutil.copy('pef.py', 'logs.log')
     5 
     6 # copy2(src, dst);Copy data and all stat info ("cp -p src dst"). Return the file's destination."
     7 shutil.copy2('pef.py', 'logs2.log')
     8 
     9 # copystat(src, dst, *, follow_symlinks=True); Copy all stat info (mode bits, atime, mtime, flags) from src to dst.
    10 shutil.copystat('pef.py', 'log.log')
    11 
    12 # copytree(src, dst, symlinks=False, ignore=None);Recursively copy a directory tree.
    13 shutil.copytree('folder1', 'folder2', ignore=shutil.ignore_patterns('*.pyc', 'tmp*'))
    14 
    15 # make_archive(base_name, format, root_dir=None, base_dir=None, verbose=0, dry_run=0, owner=None, group=None, logger=None)
    16 # Create an archive file (eg. zip or tar).
    17 # 将 C:UsersxionggexDesktopac_testlib 下的文件打包放置 C:UsersxionggexDesktop目录,lib2 为文件名
    18 shutil.make_archive(r'C:UsersxionggexDesktoplib2', 'gztar', root_dir=r'C:UsersxionggexDesktopac_testlib')
    19 # 将 /Users/wupeiqi/Downloads/test 下的文件打包放置当前程序目录,lib2 为文件名
    20 shutil.make_archive('lib2', 'zip', root_dir=r'C:UsersxionggexDesktopac_testlib')
  • 相关阅读:
    细说java中的类
    使用LayUI操作数据表格
    使用LayUI展示数据
    一步一步做搜索(一)
    试图加载格式不正确的程序
    自己实现spring核心功能 三
    SpringMvc请求处理流程与源码探秘
    设计模式之代理模式
    爬虫功能介绍
    爬虫监控帮助文档汇总
  • 原文地址:https://www.cnblogs.com/skyliao/p/9588216.html
Copyright © 2011-2022 走看看