当前位置: 首页 > news >正文

医疗器械招商网站大全网站seo怎么做

医疗器械招商网站大全,网站seo怎么做,微云做网站,可以自己设计房子的游戏学习这个的需求来自于,我想把项目架构告诉gpt问问它,然后不太会打印项目架构😂 联想到Linux的tree指令 import osclass DirectoryTree:def __init__(self, path):self.path pathdef print_tree(self, methoddefault):if method default:sel…

学习这个的需求来自于,我想把项目架构告诉gpt问问它,然后不太会打印项目架构😂 联想到Linux的tree指令

import osclass DirectoryTree:def __init__(self, path):self.path = pathdef print_tree(self, method='default'):if method == 'default':self._print_dir_tree(self.path)elif method == 'with_count':self._print_dir_tree_with_count(self.path)elif method == 'files_only':self._print_files_only(self.path)elif method == 'with_symbols':self._print_dir_tree_with_symbols(self.path)else:print("Invalid method!")def _print_dir_tree(self, path, indent=0):print(' ' * indent + '|---' + os.path.basename(path))for item in os.listdir(path):itempath = os.path.join(path, item)if os.path.isdir(itempath):self._print_dir_tree(itempath, indent + 2)else:print(' ' * (indent + 2) + '|---' + item)def _print_dir_tree_with_count(self, path, indent=0):print(' ' * indent + '|---' + os.path.basename(path), end=' ')items = os.listdir(path)dirs = sum(1 for item in items if os.path.isdir(os.path.join(path, item)))files = len(items) - dirsprint(f"(dirs: {dirs}, files: {files})")for item in items:itempath = os.path.join(path, item)if os.path.isdir(itempath):self._print_dir_tree_with_count(itempath, indent + 2)else:print(' ' * (indent + 2) + '|---' + item)def _print_files_only(self, path, indent=0):for item in os.listdir(path):itempath = os.path.join(path, item)if os.path.isdir(itempath):self._print_files_only(itempath, indent)else:print(' ' * indent + '|---' + item)def _print_dir_tree_with_symbols(self, path, indent=0):print(' ' * indent + '📁 ' + os.path.basename(path))for item in os.listdir(path):itempath = os.path.join(path, item)if os.path.isdir(itempath):self._print_dir_tree_with_symbols(itempath, indent + 2)else:print(' ' * indent + '📄 ' + item)class EnhancedDirectoryTree:def __init__(self, path):self.path = pathself.show_hidden = Falseself.depth_limit = Noneself.show_files = Trueself.show_dirs = Truedef display_settings(self, show_hidden=False, depth_limit=None, show_files=True, show_dirs=True):self.show_hidden = show_hiddenself.depth_limit = depth_limitself.show_files = show_filesself.show_dirs = show_dirsdef print_tree(self):self._print_dir(self.path)def _print_dir(self, path, indent=0, depth=0):if self.depth_limit is not None and depth > self.depth_limit:returnif self.show_dirs:print(' ' * indent + '📁 ' + os.path.basename(path))for item in sorted(os.listdir(path)):# Check for hidden files/foldersif not self.show_hidden and item.startswith('.'):continueitempath = os.path.join(path, item)if os.path.isdir(itempath):self._print_dir(itempath, indent + 2, depth + 1)else:if self.show_files:print(' ' * indent + '📄 ' + item)# 创建类的实例
tree = DirectoryTree(os.getcwd())# 使用默认方法打印
print("Default:")
tree.print_tree()# 使用带计数的方法打印
print("\nWith Count:")
tree.print_tree(method='with_count')# 使用只打印文件的方法
print("\nFiles Only:")
tree.print_tree(method='files_only')# 使用emoji
print("\nWith Symbols:")
tree.print_tree(method='with_symbols')print('================================================================')enhancedtree = EnhancedDirectoryTree(os.getcwd())# Default print
enhancedtree.print_tree()print("\n---\n")# Configure settings to show hidden files, but only up to depth 2 and only directories
enhancedtree.display_settings(show_hidden=True, depth_limit=2, show_files=False)
enhancedtree.print_tree()print("\n---\n")# Configure settings to show only files up to depth 1
enhancedtree.display_settings(show_files=True, show_dirs=False, depth_limit=1)
enhancedtree.print_tree()
  • os.getcwd(): 返回当前工作目录的路径名。

  • os.path.basename(path): 返回路径名 path 的基本名称,即去掉路径中的目录部分,只保留文件或目录的名称部分。

  • os.listdir(path): 返回指定路径 path 下的所有文件和目录的名称列表。

  • os.path.isdir(path): 判断路径 path 是否为一个目录,如果是则返回 True,否则返回 False

  • os.path.join(path, *paths): 将多个路径组合成一个完整的路径名。这个函数会自动根据操作系统的不同使用不同的路径分隔符。

  • 上面两个类里面的函数其实就是用到递归,第二个类的那个函数可以设置递归深度

http://www.mmbaike.com/news/74310.html

相关文章:

  • 个人网站可以做信息网站吗中国的网络营销公司
  • 南京网站设计与制作深圳网络营销软件
  • 个人做网站备案吗无锡网络公司
  • 自己网站上做支付宝怎么收费的河北企业网站建设
  • 秦皇岛手机网站制作价格关键词歌曲免费听
  • ae模板下载网站seo快速排名代理
  • 南县网站开发百度竞价推广收费
  • 好品质高端网站设计网络营销的概念和特点是什么
  • 网站开发前后端分工网站换友链平台
  • 企业网站优化哪家好百度移动端排名
  • 珠海网站建设设计国内新闻最新消息
  • 动态网站开发实训报告店铺运营
  • 如何在南美做网站推广东营网站建设制作
  • wordpress reset 插件seo营销技巧
  • 做网站的生产方式app推广怎么做
  • 大学生学风建设专题网站代运营公司排名
  • 网站搭建 主机推荐宁波seo推荐推广平台
  • 如何给网站做外链网络推广优化方案
  • 织梦做网站主页容易吗百度风云榜小说排行榜
  • 怎样显示隐藏的wordpressseo优化师就业前景
  • 西安网站建设设计百度账号查询
  • 怎么做收费网站优化营商环境应当坚持什么原则
  • 流量型网站 cms深圳网站建设开发公司
  • 哪些网站做的不好第一推广网
  • 电子商务网站规划与设计百度热词搜索指数
  • 建设一个网站需要学习什么站长之家seo工具包
  • 建设雅马哈摩托车官方网站新闻媒体发稿平台
  • 做网站图片自动切换营销软文推广平台
  • 网站开发绩效指标现在有哪些推广平台
  • 网站建设技术文章南宁网站建设优化服务