【发布时间】:2018-08-06 23:03:55
【问题描述】:
我有这个代码:
delIndex = []
for a in range(0, 10):
if a not in found_index and len(found_index) > 0:
delIndex.append(a)
for index in sorted(delIndex, reverse=True):
del faces[index]
此代码删除不在数组found_index中的项目
有没有办法通过使用完成这项工作或其他事情的方法来简化代码?
【问题讨论】:
-
不确定您到底想做什么。你问:“有没有办法通过使用完成这项工作或其他事情的方法来简化?”在这种情况下,什么是“另一件事”?您要简化上述代码的哪一部分?另外,
faces字典来自哪里?什么是“这份工作”? -
为什么是“numpy”标签?
-
你能保证数组是唯一的吗?如果你想从
[1,2,3,1]中删除1,你期望什么? -
欢迎来到 SO!请提供 minimal reproducible example,因为您的问题目前尚不清楚。
标签: python python-3.x numpy