📜  Python| shutil.unregister_unpack_format() 方法

📅  最后修改于: 2022-05-13 01:55:38.499000             🧑  作者: Mango

Python| shutil.unregister_unpack_format() 方法

Python中的Shutil 模块提供了许多对文件和文件集合进行高级操作的功能。它属于 Python 的标准实用程序模块。该模块有助于自动复制和删除文件和目录的过程。

Python中的shutil.unregister_unpack_format()方法用于从可用支持的解包格式列表中取消注册或删除解包格式。

我们还可以使用 shutil.register_unpack_format() 方法注册新格式或指定自己的解压现有格式的函数,或使用shutil.register_unpack_format() shutil.get_unpack_formats()获取所有支持的可用解压格式的列表。

代码: shutil.unregister_unpack_format() 方法的使用
# Python program to explain shutil.unregister_unpack_format() method  
    
# importing shutil module 
import shutil
  
# Get the list of 
# supported unpack formats
formats = shutil.get_unpack_formats()
  
# Print the list
print("Supported unpack formats:")
print(formats, "\n")
  
# Remove an unpack format
name = "gztar"
shutil.unregister_unpack_format(name)
print("%s unpack format unregistered successfully." %name, "\n")
  
# Get the list of 
# supported unpack formats
formats = shutil.get_unpack_formats()
  
# Print the list
print("Supported unpack formats:")
print(formats, "\n")
输出:

参考: https://docs。 Python.org/3/library/shutil.html