import os
class 文件对象:
def __init__(self,item_path,item_name):
self.path=item_path
self.name=item_name
def __str__(self):
n=self.path.count('\\')
#return "┠{} {}\n".format('━'*n,self.name)
return '{}<a href={}>{}</a><br>\n'.format(" "*2*n,self.path.replace(' ','%20'),self.name)
class 文件夹对象:
def __init__(self,item_path,content=None):
#print('before:',item_path)
self.path=item_path
if content is None:
self.content=[]
if os.path.isdir(self.path):
self.name=self.path.split('\\')[-1]
content=[]
if self.name:
def key_func(x):
try:
return int(x.split('、')[0])
except (TypeError,ValueError) as err:
return 999
将当前目录下文件生成带有链接的html目录
最新推荐文章于 2023-07-05 11:20:25 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)