struct_py_dict
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| struct_py_dict [2017/06/30 13:35] – gg | struct_py_dict [2017/06/30 13:42] (current) – gg | ||
|---|---|---|---|
| Line 5: | Line 5: | ||
| <code python> | <code python> | ||
| # Das dictionary erstellen: | # Das dictionary erstellen: | ||
| - | dict = {" | + | dictionary |
| + | # Andere Syntax, um das dictionary zu erstellen: | ||
| + | dictionary = dict([(" | ||
| # Ausgabe des dicts | # Ausgabe des dicts | ||
| - | print(dict) # Ausgabe wird sein: {' | + | print(dictionary) # Ausgabe wird sein: {' |
| # Ausgabe der Elemente | # Ausgabe der Elemente | ||
| - | print(dict.items()) # Ausgabe wird sein: dict_items([(' | + | print(dictionary.items()) # Ausgabe wird sein: dict_items([(' |
| # Über das dictionary Iterieren und etwas damit ausgeben | # Über das dictionary Iterieren und etwas damit ausgeben | ||
| - | for key, value in dict.items(): | + | for key, value in dictionary.items(): |
| print(" | print(" | ||
| # Zugreifen über den Schlüssel | # Zugreifen über den Schlüssel | ||
| - | print(" | + | print(" |
| </ | </ | ||
struct_py_dict.1498822552.txt.gz · Last modified: 2017/06/30 13:35 by gg
