📜  在 python 代码示例中对集合进行排序

📅  最后修改于: 2022-03-11 14:45:52.133000             🧑  作者: Mango

代码示例1
#Update: As of Python 3.7 (and CPython 3.6), standard dict is 
    #guaranteed to preserve order and is more performant than OrderedDict. 
#(For backward compatibility and especially readability, 
    #however, you may wish to continue using OrderedDict.)

>>> keywords = ['foo', 'bar', 'bar', 'foo', 'baz', 'foo']

>>> list(dict.fromkeys(keywords))
['foo', 'bar', 'baz']