且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何正确传递文字字符串python代码以使用python -c执行

更新时间:2023-11-05 16:20:40

如果您确实确实需要进行单行破解(完全不建议或纵容),则可以这样做

If you really really need to do a one line hack (this is totally not suggested or condoned) then you can do this

python -c "import os; import shutil; for root, dirs, files in os.walk('+myPath+'): for file in files: os.remove(os.path.join(root, file)); for dir in dirs: shutil.rmtree(os.path.join(root, dir))"

但是您真正应该做的是将其设置为Windows路径中的脚本,然后就可以完成

But what you should really do is make this a script that is inside your windows path, then you can do

python myfancyscript.py

哪个好很多了?