程序问答   发布时间:2022-05-31  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了我可以在 python 脚本上执行 Windows 中的 unzip 等价物吗?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_489_0@如何解决我可以在 python 脚本上执行 Windows 中的 unzip 等价物吗?? 开发过程中遇到我可以在 python 脚本上执行 Windows 中的 unzip 等价物吗?的问题如何解决?下面主要结合日常开发的经验,给出你关于我可以在 python 脚本上执行 Windows 中的 unzip 等价物吗?的解决方法建议,希望对你解决我可以在 python 脚本上执行 Windows 中的 unzip 等价物吗?有所启发或帮助;

我在 Jupyter Notebook 上有一个脚本,可以解压缩文件、创建目录并将解压缩的文件移动到这些目录。但是,该脚本仅适用于 *nix 操作系统。

# the name of your folder where the LIEF files are
lIEf_data_folder = 'Images' 

# Is the Account Multi-store? (True/falsE)
is_multi_store = false

# set the path
base_path = os.getcwd()
raw_data = base_path+'/'+lIEf_data_folder

# unzip and move file
os.chdir(raw_data)
!for z in *.zip; do unzip -d _$z -o "$z"; done
!mkdir 'products'
!for item in _product_2020*;do mv -f $item 'products'; done
!mkdir 'products_photo'
!for item in _product_photo_*;do mv -f $item 'products_photo'; done
!mkdir 'raw_zip'
!for item in *.lIEf-packet.zip;do mv -f $item 'raw_zip'; done
!mv 'Data Export Log' 'raw_zip'
!mv 'Data Export SumMary' 'raw_zip'
os.chdir(base_path)

print('DONE')

我知道 mv 在 windows 中是移动的,但是 unzip 或更好的 windows 解决方案是什么? 还有 mv 中上述选项的等价物是什么?

@H_489_0@解决方法

Python 有模块 zipfile 来压缩/解压缩文件。和 shutil.unpack_archive() 表示 ziptar

您也可以像在 Linux 中一样使用 unzip 中的 GnuWin32 安装 zip

GnuWin32 中还有其他有用的程序 - 即。 CoreUtils 中的 @H_782_5@mv、ls、@H_782_5@mkdir。

或者您可以尝试 Windows Subsystem for Linux,您将在 Windows 中拥有 Linux 终端。


我使用 Linux 并且我不能说它是如何工作的 WSL很久以前当我使用 Windows
然后我一直在使用来自 GnuWin32

的工具

大佬总结

以上是大佬教程为你收集整理的我可以在 python 脚本上执行 Windows 中的 unzip 等价物吗?全部内容,希望文章能够帮你解决我可以在 python 脚本上执行 Windows 中的 unzip 等价物吗?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。