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')
  • 相关阅读:
    sqlalchemy 使用pymysql连接mysql 1366错误
    mysql之数据导出
    Go常见语句
    huffman code
    后缀数组,目前比较赶进度,而且有点难,所以放到以后再来看
    hash
    bipartite matching
    spanning tree
    拓扑排序
    Union Find
  • 原文地址:https://www.cnblogs.com/skyliao/p/9588216.html
Copyright © 2011-2022 走看看