@ 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.
versucht.
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)
Ergebnis
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'])
Das Wörterbuch ist nur der Schlüssel.
@ No.1731 / 12833
When you give set() a dictionary, it uses only the keys:
@ shiracamus 'Kommentar hat mir beigebracht, wie man Wörterbuchwerte abruft.
Ich habe auch Folgendes gelernt.
dir({})
help({})
help({}.values)
Danke für die Information.
Recommended Posts