@ Introducing Python: Modern Computing in Simple Packages by Bill Lubanovic (No. 1721 / 12833)
You can create a set from a list, string, tuple, or dictionary, discarding any duplicative values.
a essayé.
http://ideone.com/y39M6a
astring = set( 'letters' )
print(astring)
alist = set( [ 3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5])
print(alist)
atuple = set( (3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5))
print(atuple)
adict = set( { 'item1': 'double edged sword', 'item2': 'Korejanai Robo'} )
print(adict)
résultat
Success time: 0 memory: 23304 signal:0
set(['s', 'r', 'e', 'l', 't'])
set([1, 2, 3, 4, 5, 6, 9])
set([1, 2, 3, 4, 5, 6, 9])
set(['item2', 'item1'])
Le dictionnaire n'est que la clé.
@ No.1731 / 12833
When you give set() a dictionary, it uses only the keys:
Le [Comment] de @ shiracamus (http://qiita.com/7of9/items/c1958d662ec776f7df61/#comment-84bc16dbf992ba52ed26) m'a appris à récupérer les valeurs du dictionnaire.
J'ai également appris ce qui suit.
dir({})
help({})
help({}.values)
Merci pour l'information.