我正在寻找一种快速简便的方法来检查数组中的所有项目是否都是唯一的.
unique = ['one', 'two']
unique = []
not_unique = ['one', 'one', 'two']
Run Code Online (Sandbox Code Playgroud)
# As simple as possible:
not_unique == not_unique.uniq
# or perhaps
not_unique.size == not_unique.uniq.size
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2628 次 |
| 最近记录: |