我想从以下列表中获取唯一值:
['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 ×1