我希望能够删除列表中不需要的一些单词。
代码:
txt = document.getElementById('title').innerHTML
alert(txt)
输出:
{"Name":"Item Name", "Weight in store":12.3, "Minimum Purchase":12, "Purchase Price":19.99, "Category":"That Thing", "Location":"That Place"},
{"Name":"Other Name", "Weight in store":32.1, "Minimum Purchase":16, "Purchase Price":29.99, "Category":"Other Thing", "Location":"Other Place"}
contour = cnt
stopwords = ['array', 'dtype=int32']
for word in list(contour):
if word in stopwords:
contour.remove(word)
print(contour)
如何删除[array([[[21, 21]],
[[21, 90]],
[[90, 90]],
[[90, 21]]], dtype=int32)]
和FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
if word in stopwords:
,同时使列表只是两点的列表?
例如:
dtype=int32
答案 0 :(得分:0)
使用numpy.ndarray.tolist()
:
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]]]]