Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 从嵌套列表中删除不需要的文本_Python - Fatal编程技术网

Python 从嵌套列表中删除不需要的文本

Python 从嵌套列表中删除不需要的文本,python,Python,我希望能够删除一些我不想在列表中出现的单词 代码: 输出: [array([[[21, 21]], [[21, 90]], [[90, 90]], [[90, 21]]], dtype=int32)] FutureWarning:元素级比较失败;而是返回标量,但将来将执行元素级比较 如果单词在stopwords中: 如何删除dtype=int32和array,同时使列表仅包含两点 例: 使用numpy.ndarray.tolist(): 输出:

我希望能够删除一些我不想在列表中出现的单词

代码:

输出:

[array([[[21, 21]],

       [[21, 90]],

       [[90, 90]],

       [[90, 21]]], dtype=int32)]
FutureWarning:元素级比较失败;而是返回标量,但将来将执行元素级比较
如果单词在stopwords中:

如何删除
dtype=int32
array
,同时使列表仅包含两点

例:


使用
numpy.ndarray.tolist()

输出:

[[[[21, 21]], [[21, 90]], [[90, 90]], [[90, 21]]]]

此数据结构的类型是什么?@balderman numpy arrayCall
tolist()
,以便将其转换为python列表。看见
[[21, 21],

 [21, 90],

 [90, 90],

 [90, 21]]
import numpy as np

l = np.array(
    [np.array([[[21, 21]],

       [[21, 90]],

       [[90, 90]],

       [[90, 21]]], dtype="int32")]
)
l.tolist()
[[[[21, 21]], [[21, 90]], [[90, 90]], [[90, 21]]]]