Skip to content

Instantly share code, notes, and snippets.

@feiandxs
Created April 1, 2022 10:01
Show Gist options
  • Save feiandxs/db3537e6c567d2aa8a72dead0baa1478 to your computer and use it in GitHub Desktop.
Save feiandxs/db3537e6c567d2aa8a72dead0baa1478 to your computer and use it in GitHub Desktop.
delete all pycache directory
import os
def clear(filepath):
files = os.listdir(filepath)
for fd in files:
cur_path = os.path.join(filepath, fd)
if os.path.isdir(cur_path):
if fd == "__pycache__":
print("rm %s -rf" % cur_path)
os.system("rm %s -rf" % cur_path)
else:
clear(cur_path)
if __name__ == "__main__":
clear("./")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment