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')
  • 相关阅读:
    centos7使用supermin制作centos7的docker镜像包
    Linux ip netns 命令
    ip命令讲解
    openstack API应用用
    在EF6.0中打印数据库操作日志
    EF记录统一添加创建,修改时间
    Inner Join and Left Join 与条件的结合
    字符串分割
    居中方案
    移动 前端 框架
  • 原文地址:https://www.cnblogs.com/skyliao/p/9588216.html
Copyright © 2011-2022 走看看