python achieve all of the files in batch to delete a certain path

#coding=utf-8
import os

def readFilename(file_dir):
for root, dirs, files in os.walk(file_dir):
return files,dirs,root
def deleteFilesEndWithPYC(files,dirs,root):
for ii in files:
if ii.endswith(’.pyc’):
print ‘delete:’,ii
os.remove(os.path.join(root,ii))
for jj in dirs:
fi,di,ro = readFilename(root+"\"+jj)
deleteFilesEndWithPYC(fi,di,ro)

IF name == ' main ':
Files, dirs, readFilename the root = (U "D: \ bin20171111 \ Lib")
deleteFilesEndWithPYC (Files, dirs, the
root) ----------------
Disclaimer: this article is the original article CSDN bloggers "quicksand Shen Hai", and follow CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
Original link: https: //blog.csdn.net/lishenluo/article/details/79244210

Published 41 original articles · won praise 7 · views 3704

Guess you like

Origin blog.csdn.net/weixin_43091087/article/details/100932975