标签:mes inux end ring pop split 文件 linu []
import os def getAllFile(*names): if len(names) == 0: return "" else: allList = [] for name in names: fileAndDirString = os.popen("ls -l "+name).read() fileAndDirStringDo = "\n".join(fileAndDirString.split("\n")[1:-1]) if fileAndDirStringDo: fileAndDirList = [fileOrDir.split(" ")[0]+" "+name+"/"+fileOrDir.split(" ")[-1] for fileOrDir in fileAndDirStringDo.split("\n")] allList.extend(fileAndDirList) # print(allList) fileList = [] dirList = [] for fileAndDir in allList: # print(fileAndDir) if fileAndDir[0] == "-": fileList.append(fileAndDir.split(" ")[-1]) else: dirList.append(fileAndDir.split(" ")[-1]) return "\n".join(fileList)+"\n"+getAllFile(*dirList) r = getAllFile("/home/taomin") print(r)
标签:mes inux end ring pop split 文件 linu []
原文地址:https://www.cnblogs.com/taomin/p/10459528.html