(SRC) Else: Copy2 (SRC, real_dst) os.unlink (SRC)Make_archiveShutil.make_archive (base_name, Format,...)Create a compressed package and return the file path, for example: Zip, tar
base_name: The file name of the compressed package, or the path to the compressed package. When the file name is only, save to the current directory, otherwise save to the specified path,
format: Compressed package type, "Zip", "tar", "Bztar", "Gztar
(base_ Name, format, ...) : Create a compressed package and return the file path, for example: Zip, Tarbase_name: The file name of the compressed package, or the path to the compressed package. Only the file name is saved to the current directory, otherwise saved to the specified path such as:www=> saved to the current path such as:/users/alex/www = Save to/users/alexformat: Package type, "Zip", "tar", "Bztar" , "Gztar" Root_dir: Folder path to compr
*‘)) #目标目录不能存在,注意对folder2目录父级目录要有可写权限,ignore的意思是排除Shutil.rmtree (path[, ignore_errors[, OnError])To delete a file recursivelyimport shutilshutil.rmtree(‘folder1‘)Shutil.move (SRC, DST)To move a file recursively, it is like the MV command, which is actually renamed.import shutilshutil.move(‘folder1‘, ‘folder3‘)Shutil.make_archive (base_name, Format,...)Create a compressed package and return the file path, for example: Zip, tarCreate a compressed package and return the file path, for example: Zip,
options in the setup Script or config file), sdist creates the Archive of the default format for the current platform. The default format is a gzip "Ed tar file (. tar.gz) on Unix, and ZIP file on Windows.You can specify as many formats as if using the --formats option, for example:Python setup.py sdist--formats=gztar,zipTo create a gzipped tarball and a zip file. The available formats is:
Format
Description
/
Format: Compressed package type, "Zip", "tar", "Bztar", "Gztar"
Root_dir: Folder path to compress (default current directory)
Owner: User, default Current user
Group: Groups, default current group
Logger: Used to log logs, usually logging. Logger Object#将/users/wupeiqi/downloads/test file package to place the current program directory Import Shutilret = shutil.make_archive ("wwwwwwwwww", ' Gz
Shutil‘‘‘1.base_bak: The name of the compressed file, the file name of the compressed package (you can also specify the specific file directory to compress the saved)such as data_bak=> save to current pathsuch as:/tmp/data_bak = Save to/tmp/2.gztar: Compressed package type, "Zip", "tar", "Bztar", "Gztar"3.root_dir: Path of the compressed file (default current directory)4.owner: User, default Current user5.
to the specified path,For example: www + = Save to Current pathsuch as:/users/wupeiqi/www = Save to/users/wupeiqi/
Format: Compressed package type, "Zip", "tar", "Bztar", "Gztar"
Root_dir: Folder path to compress (default current directory)
Owner: User, default Current user
Group: Groups, default current group
Logger: Used to log logs, usually logging. Logger Object
12345678
#将 /Users/wupeiqi/Downloads/
, it can be downloaded from a domestic image: Http://golangtc.com/download/package
Mkdir-p $GOPATH/src cd $GOPATH/src wget HTTP://GOLANGTC. com/static/download/packages/code. Google. com. P. Go-tour. Tar. GZwget HTTP://GOLANGTC. com/static/download/packages/code. Google. com. P. Go. NET. Tar. GZwget HTTP://GOLANGTC. com/static/download/packages/code. Google. com. P. Go. Tools. Tar. GZtar XF Code. Google. com. P. Go. NET. Tar.
command, is actually renaming
import shutiL
shutil.move('folder1', 'folder3')
(11)Shutil. make_archive (base_name, format ,...)
Create a compressed package and return the file path, such as zip and tar.
Create a compressed package and return the file path, such as zip and tar.
Base_name: the file name of the compressed package. It can also be the path of the compressed package. Only when the file name is used, it is saved to the current directory; otherwise, it is saved to the specified path.
F
) recursively de-copying files such as: copytree (source, destination, ignore= Ignore_patterns (' *.pyc ', ' tmp* ')) shutil.rmtree (path[, ignore_errors[, onerror]) recursively remove files Shutil.move (src, dst) Recursive go-to-move file shutil.make_archive (base_name, format,...) Create a compressed package and return the file path, for example: zip, tarbase_name: The file name of the compressed package, or the path to the compressed Package. is only the file name, save to the current directo
First method one, download unzipwget http://mirrors.hust.edu.cn/apache//httpd/httpd-2.4.29.tar.gzwget https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.6.3.tar.gzwget https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.6.1.tar.gztar -vxf httpd-2.4. . tar. gzTAR-VXF apr-1.6.3.tar.gzTAR-VXF apr-util-1.6.1.tar.gzSecond, install the development package group and related dependent packagesYum " Development Tools " Yum Install openssl-devel pcr
+ = Save to Current pathsuch as:/users/wupeiqi/www = Save to/users/wupeiqi/
Format: Compressed package type, "Zip", "tar", "Bztar", "Gztar"
Root_dir: Folder path to compress (default current directory)
Owner: User, default Current user
Group: Groups, default current group
Logger: Used to log logs, usually logging. Logger Object
12345678
#将 /Users/wupeiqi/Downloads/test 下的文件打包放置当前程序目录importshutilret=shutil.ma
returns its name. Base_name file name. Format compressed, "Zip", "tar", "Bztar" or "Gztar". Root_dir the root directory of the compression. Base_dir begins the compressed directory. Root_dir and Base_dir are the current directories by default. Owners and groups default to the current user and group; logger is logging. An instance of logger.Shutil.get_archive_formats (): Returns a list of supported formats. Default support:
Gztar:gzip Compres
to current path such as:/users/wupeiqi/www = Save to/users/wupeiqi/Format: Compressed package type, "Zip", "tar", "Bztar", "Gztar" Root_dir: Folder path to compress (default current directory) Owner: User, default Current user group: groups, default current group logger : Used to log logs, usually logging. Logger Object#package files under/users/wupeiqi/downloads/test to place the current program directory ImportShutilret= Shutil.make_archive ("wwwww
folderShutil.copytree (' Folder1 ', ' Folder2 ', ignore=shutil.ignore_patterns (' *.pyc ', ' tmp* ')) #目标目录不能存在, Note for Folder2 directory parent directory to have writable permissions, ignore means to exclude Shutil.rmtree (path[, ignore_errors[, OnError])To delete a file recursivelyShutil.rmtree (' Folder1 ') # recursively go to delete files directory Shutil.move (SRC, DST)To move a file recursively, it is like the MV command, which is actually renamed.Shutil.move (' Folder1 ', ' Folder
Zip:Zip [file name after compression] [source file] Zip compression-R compression directory (not packaged, each of the files becomes a zip)Unzip [file or directory] Zip decompressionGzgzip [source file] The source file disappears after compressing-C > Xxx.gzip can not disappear with output directional characters-R DirectoryGunzip = gzip-d DecompressionBZ2:bzip2 [Source file] The source file disappears after compressing-K Preserve Source filesNote: This command cannot compress the directoryBUNZIP
[format] except Keyerror: raise ValueError ("Unknown ARCHIVE format '%s '"% Format) func = format_info[0] for Arg, Val in format_info[1]: kwargs[arg] = val if format! = ' Zip ':
kwargs[' owner ' = owner kwargs[' Group '] = Group try: filename = func (base_name, Base_dir, **kwargs) finally: if Root_dir is not none: the if Logger is not none: logger.debug ("Changing Back to '%s '", Save_c WD) Os.chdir (SAVE_CWD) return filename
Base_name: Compress the pac
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.