使用操作员复制多维数组的元素
我有这样的代码:
array = [['x', 3], ['y', 3]*2]
print(array)
输出:
>> [['x', 3], ['y', 3, 'y', 3]]
,但是,我想获得的结果是:[[['x',3],['' y',3],['y',3]]
我的问题是,如何使用 operators 复制多维数组的某个元素?
I have a code that goes like this:
array = [['x', 3], ['y', 3]*2]
print(array)
Output:
>> [['x', 3], ['y', 3, 'y', 3]]
However, the result that I want to get is: [['x', 3], ['y', 3], ['y', 3]]
My question is, how do you duplicate a certain element of a multi-dimensional array using operators?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道操作员的方法,但是
您可以使用
copy()
检查 docs复制所需的元素,然后将其添加到数组中,
您可以创建新的类类型并自定义运算符功能
I don't know a way for Operators But,
You can Use
copy()
Check the DocsCopy the element you want then add it to the array
You can create a new class type and customize the Operators functionality for it