fork download
  1. print("--- AI训练常用工具 ---") # 增加行1:打印标题
  2. tools = ["TensorFlow", "PyTorch", "Keras"]
  3. print("初始工具列表:", tools )
  4. print("当前工具数量:", len(tools) ) # 增加行2:打印列表长度
  5. print("每个工具名称:") # 增加行3:提示下面逐项打印
  6. for t in tools: # 增加行4:循环逐项打印
  7. print(" -", t ) # 增加行5:打印单个工具
  8.  
  9.  
  10. print("\n--- 添加新工具 ---")
  11. new_tools = ["Scikit-learn", "MXNet"]
  12. for tool in new_tools:
  13. if tool not in tools:
  14. tools. append (tool)
  15. else:
  16. print(f"工具 '{tool}' 已存在,跳过添加")
  17.  
  18. print("\n更新后的工具列表:",tools )
Success #stdin #stdout 0.07s 13968KB
stdin
Standard input is empty
stdout
--- AI训练常用工具 ---
初始工具列表: ['TensorFlow', 'PyTorch', 'Keras']
当前工具数量: 3
每个工具名称:
 - TensorFlow
 - PyTorch
 - Keras

--- 添加新工具 ---

更新后的工具列表: ['TensorFlow', 'PyTorch', 'Keras', 'Scikit-learn', 'MXNet']