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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
