几乎我需要编写一个程序来检查列表是否有任何重复项,如果有,它会删除它们并返回一个新列表,其中包含未复制/删除的项目.这就是我所拥有的,但说实话,我不知道该怎么做.
def remove_duplicates():
t = ['a', 'b', 'c', 'd']
t2 = ['a', 'c', 'd']
for t in t2:
t.append(t.remove())
return t
Run Code Online (Sandbox Code Playgroud) 我想从以下列表中获取唯一值:
['nowplaying', 'PBS', 'PBS', 'nowplaying', 'job', 'debate', 'thenandnow']
Run Code Online (Sandbox Code Playgroud)
我需要的输出是:
['nowplaying', 'PBS', 'job', 'debate', 'thenandnow']
Run Code Online (Sandbox Code Playgroud)
此代码有效:
output = []
for x in trends:
if x not in output:
output.append(x)
print(output)
Run Code Online (Sandbox Code Playgroud)
我应该使用更好的解决方案吗?
我试图在Python中实现大量的矩阵 - 矩阵乘法.最初,我假设NumPy将自动使用我的线程BLAS库,因为我是针对这些库构建的.但是,当我查看顶部或其他内容时,似乎代码根本不使用线程.
任何想法是什么错误或我可以做些什么来轻松使用BLAS性能?