【Python报错】 list indices must be integers or slices, not tuple结合相关概念

编程入门 行业动态 更新时间:2024-10-19 18:19:31

【Python<a href=https://www.elefans.com/category/jswz/34/1771188.html style=报错】 list indices must be integers or slices, not tuple结合相关概念"/>

【Python报错】 list indices must be integers or slices, not tuple结合相关概念

1. list indices must be integers or slices, not tuple

  • 列表索引必须是整数(例如:data[0])或者片(例如data[0:2])。
  • 不能是元组(tuple是元组的意思)。
  • 列表 [ ]:按特定顺序排列的元素组成,样式[ ],用逗号分隔其中元素。
  • 元组 ( ):不可变的列表,不可变即不能修改值。样式 ( ),用逗号分隔其中元素。

2.查看类型-程序debug后,鼠标放置对应位置即可查看

readout_244:列表样式

[AddReadout(), AddReadout(), AddReadout(), AddReadout()]

readout_384: 内部元组样式

 [ProjectReadout((project):Sequential((0):Linear(in_featurers=1536, out_features=768, bias=True)(1):GELU())),ProjectReadout((project):Sequential((0):Linear(in_featurers=1536, out_features=768, bias=True)(1):GELU())),ProjectReadout((project):Sequential((0):Linear(in_featurers=1536, out_features=768, bias=True)(1):GELU())),ProjectReadout((project):Sequential((0):Linear(in_featurers=1536, out_features=768, bias=True)(1):GELU()))
]

显然格式不符合,考虑进一步修改!

更多推荐

【Python报错】 list indices must be integers or slices, not tuple结合相关概念

本文发布于:2024-02-11 11:48:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1680833.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:报错   概念   list   Python   indices

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!