标签:highlight 目录 lis charm har spl list arm imp
感觉这个没什么好说的:
import os def rev(path: str, i=0): s = ‘+‘ * i + path.split(‘/‘)[-1] + ‘\n‘ for _ in os.listdir(path): if os.path.isdir(path + ‘/‘ + _): s += rev(path + ‘/‘ + _, i + 1) + ‘\n‘ elif os.path.isfile(path + ‘/‘ + _): s += ‘+‘ + ‘+‘ * i + _ + ‘\n‘ return s print(rev(‘D:/PycharmProjects‘))
标签:highlight 目录 lis charm har spl list arm imp
原文地址:https://www.cnblogs.com/darkchii/p/12757890.html