Comment detail
アレイのuniq (Nested Flatten)This comment is reply for 524 bonlife: Python界隈に足りないのは素人だと思...(アレイのuniq). Go to thread root.
誰も言及しないようなので… Python2.5では下のようにset(xs)で要素の重複を取り除くことができますが、 これは「集合型」なので順序が保存されません。 速度が問題にならないのであれば sortedを使って元の順番に並べ直してやるのも手です。
1 2 3 4 5 6 7 | >>> xs = list("314159265358979")
>>> xs
['3', '1', '4', '1', '5', '9', '2', '6', '5', '3', '5', '8', '9', '7', '9']
>>> set(xs)
set(['1', '3', '2', '5', '4', '7', '6', '9', '8'])
>>> sorted(set(xs), key = xs.index)
['3', '1', '4', '5', '9', '2', '6', '8', '7']
|





にしお
#529()
[
Python
]
Rating1/1=1.00
Rating1/1=1.00-0+