Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有不同类型的未知变量(在 ABAQUS 中,它显示“序列”)并希望通过循环将它们组合起来:
a = [[unknown type], [unknown type], ...] x = [] for i in a: x.append(i)
现在的问题是,当我用 = [] 初始化 x 时,我收到错误消息
TypeError:只能将列表(不是“序列”)连接到列表。
是否有另一种(简单/高效)方式,例如在第一个循环中自动创建 x ?
使用列表理解:
x = [v for v in a]