使用pop从2D数组中删除元素 [英] Using pop for removing element from 2D array

查看:64
本文介绍了使用pop从2D数组中删除元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在下面的随机数组中:

a = [[1,2,3,4],
     [6,7,8,9]] 

能否请您告诉我如何删除特定位置的元素.例如,如何删除a[1][3]?

Could you please tell me how to remove element at a specific position. For example, how would I remove a[1][3]?

我了解list.pop在这里仅用于列表类型DS.

I understand list.pop is used for only list type DS here.

推荐答案

简单,只需在列表项上弹出即可.

Simple, just pop on the list item.

>>> a = [[1,2,3,4], [6,7,8,9]]
>>> a[1].pop(3)
>>> a
[[1, 2, 3, 4], [6, 7, 8]]

这篇关于使用pop从2D数组中删除元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆