Discuss / Python / 第二题

第二题

Topic source

import os join=os.path.join

def fileprint(path,relative=''): rpath=join(path,relative) for file in [x for x in os.listdir(rpath) if os.path.isfile(join(rpath,x))]: print(join(relative,file)) for dir in [x for x in os.listdir(rpath) if os.path.isdir(join(rpath,x))]: fileprint(path,join(relative,os.path.split(dir)[1])) fileprint('F:\nox') 跑是可以跑,不过有什么方法可以少用点join么


  • 1

Reply