我无法递归地从我的 Python 项目中删除 pyc 文件。
这是项目:
Directory: C:\Users\jk025523\projects\ex47 Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 10/07/2016 01:52 bin d----- 10/07/2016 01:52 docs d----- 10/07/2016 01:52 ex47 d----- 10/07/2016 01:52 tests -a---- 09/07/2016 21:02 521 setup.py
There are indeed some pyc files inside the tests directory:
Directory: C:\Users\jk025523\projects\ex47\tests Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 09/07/2016 21:28 180 ex47_tests.py -a---- 09/07/2016 21:28 721 NAME_tests.pyc -a---- 05/07/2016 10:52 0 __init__.py -a---- 05/07/2016 11:37 140 __init__.pyc
However when I enter this command in PowerShell to remove all the pyc files:
find . -name "*.pyc" -exec rm -rf {}
PowerShell 输出此错误:
FIND: Parameter format not correct
有人知道如何从这个 Python 项目中删除所有 pyc 文件吗?
最佳答案
您尝试使用的命令是 Linux/Unix find
命令,它在 Windows 上不起作用(除非你安装了类似 Cygwin 的东西,我不推荐这样做)。 Windows 有一个 command with the same name ,但功能不同(更像 grep
)。 PowerShell 没有 find
cmdlet 或别名。您将在 PowerShell 中递归删除具有特定扩展名的文件:
Get-ChildItem -Filter '*.pyc' -Force -Recurse | Remove-Item -Force
关于powershell - 无法从 Python 项目中递归删除 pyc 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38287651/