gpt4 book ai didi

powershell - 无法从 Python 项目中递归删除 pyc 文件

转载 作者:行者123 更新时间:2023-12-04 01:19:17 24 4
gpt4 key购买 nike

我无法递归地从我的 Python 项目中删除 pyc 文件。

这是项目:

    Directory: C:\Users\jk025523\projects\ex47Mode                LastWriteTime         Length Name----                -------------         ------ ----d-----       10/07/2016     01:52                bind-----       10/07/2016     01:52                docsd-----       10/07/2016     01:52                ex47d-----       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\testsMode                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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com