Get a list from a set in python

后端 未结 3 666
灰色年华
灰色年华 2020-12-28 11:29

Ho do I get the contents of a set() in list[] form in Python?

I need to do this because I need to save the collection in Google App Engine

3条回答
  •  执念已碎
    2020-12-28 12:08

    >>> a = [1, 2, 3, 4, 2, 3]
    >>> b = set(a)
    >>> b
    set([1, 2, 3, 4])
    >>> c = list(b)
    >>> c
    [1, 2, 3, 4]
    >>> 
    

提交回复
热议问题