Discuss / Python / 交作业2

交作业2

Topic source

import os def myfile(path,postfix,reldir): for f in os.listdir(path):
if os.path.isdir(os.path.join(path,f)): reldir = os.path.join(reldir,f) myfile(os.path.join(path,f),postfix,reldir)
else: if f.find(postfix) != -1: print('相对路径:{},文件名:{}'.format(reldir,f))

postfix = 'csv' #指定字符串 myfile(R'D:\dirtest',postfix,'')


  • 1

Reply