Python中的Shutil模块提供了许多对文件和文件集合进行高级操作的函数。它属于Python的标准实用程序模块。该模块有助于自动执行文件和目录的复制和删除过程。
shutil.unregister_archive_format()Python中的方法用于从可用的支持存档格式列表中注销或删除存档格式。
我们还可以注册新格式或使用以下函数指定自己的函数来归档现有格式shutil.register_archive_format()方法或使用以下命令获取所有受支持的可用归档格式的列表shutil.get_archive_formats()方法。
用法: shutil.unregister_archive_format(name)
参数:
name:一个字符串,代表将从列表中删除的存档格式的名称。
返回类型:此方法不返回任何值。
# Python program to explain shutil.unregister_archive_format() method
# importing shutil module
import shutil
# Get the list of
# supported archive formats
formats = shutil.get_archive_formats()
# Print the list
print("Supported archive formats:")
print(formats, "\n")
# Remove an archive format
name = "bztar"
shutil.unregister_archive_format(name)
print("'% s' archive format unregistered successfully." % name, "\n")
# Get the list of
# supported archive formats
formats = shutil.get_archive_formats()
# Print the list
print("Supported archive formats:")
print(formats, "\n")Supported archive formats:
[(‘bztar’, [‘.tar.bz2’, ‘.tbz2’], “bzip2’ed tar-file”), (‘gztar’, [‘.tar.gz’, ‘.tgz’], “gzip’ed tar-file”), (‘tar’, [‘.tar’], ‘uncompressed tar file’), (‘xztar’, [‘.tar.xz’, ‘.txz’], “xz’ed tar-file”), (‘zip’, [‘.zip’], ‘ZIP file’)]‘bztar’ archive format unregistered successfully.
Supported archive formats:
[(‘gztar’, “gzip’ed tar-file”), (‘tar’, ‘uncompressed tar file’), (‘xztar’, “xz’ed tar-file”), (‘zip’, ‘ZIP file’)]
参考: https://docs.python.org/3/library/shutil.html
相关用法
- Python next()用法及代码示例
- Python os.dup()用法及代码示例
- Python set()用法及代码示例
- Python Decimal max()用法及代码示例
- Python PIL ImageOps.fit()用法及代码示例
- Python os.rmdir()用法及代码示例
- Python sympy.det()用法及代码示例
- Python Decimal min()用法及代码示例
- Python os.readlink()用法及代码示例
- Python os.writev()用法及代码示例
- Python os.readv()用法及代码示例
- Python PIL RankFilter()用法及代码示例
- Python os.rename()用法及代码示例
- Python os.sendfile()用法及代码示例
注:本文由纯净天空筛选整理自ihritik大神的英文原创作品 Python | shutil.unregister_archive_format() method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
