fork download
  1. # 定义列表,存储3个常用标注工具名称
  2. tools = ["LabelMe", "VIA", "CVAT"]
  3. # 输出原始列表
  4. print("=" * 40)
  5. print("工具列表")
  6. print("创建的列表内容为:", tools )
  7. print("列表长度(工具个数):", len(tools ))
  8. print("第一个工具是:", tools[0] )
  9. print("最后一个工具是:", tools[-1])
  10. print()
  11. print("=" * 40)
  12. print("工具介绍(使用循环)")
  13. # 使用循环遍历列表中的每个工具
  14. index = 1 # 增加序号变量
  15. for tool in tools:
  16. # 生成介绍语句
  17. description = f"工具:{tool} —— 适用于数据标注"
  18. # 带序号输出,更清晰
  19. print(f"{index}. {description}")
  20. print(index) # 序号递增
  21. # 额外输出循环结束提示
  22. print("\n循环遍历完成!总共输出了", len(tools) , "个工具的介绍。")
Success #stdin #stdout 0.07s 14184KB
stdin
Standard input is empty
stdout
========================================
工具列表
创建的列表内容为: ['LabelMe', 'VIA', 'CVAT']
列表长度(工具个数): 3
第一个工具是: LabelMe
最后一个工具是: CVAT

========================================
工具介绍(使用循环)
1. 工具:LabelMe —— 适用于数据标注
1
1. 工具:VIA —— 适用于数据标注
1
1. 工具:CVAT —— 适用于数据标注
1

循环遍历完成!总共输出了 3 个工具的介绍。