filmov
tv
python for hacking tutorial part4 get to know dictionary in python

Показать описание
python for hacking tutorial part4 get to know dictionary in python
The Python dictionary data structure provides a hash table that can store
any number of Python objects. The dictionary consists of pairs of items that
contain a key and value. Let’s continue with our example of a vulnerability
scanner to illustrate a Python dictionary. When scanning specific TCP ports, it
may prove useful to have a dictionary that contains the common service names
for each port. Creating a dictionary, we can lookup a key like ftp and return the
associated value 21 for that port.
When constructing a dictionary, each key is separated from its value by a colon,
and we separate items by commas. Notice that the method .keys() will return
a list of all keys in the dictionary and that the method .items() will return an
entire list of items in the dictionary. Next, we verify that the dictionary contains
a specific key (ftp). Referencing this key returns the value 21.
The Python dictionary data structure provides a hash table that can store
any number of Python objects. The dictionary consists of pairs of items that
contain a key and value. Let’s continue with our example of a vulnerability
scanner to illustrate a Python dictionary. When scanning specific TCP ports, it
may prove useful to have a dictionary that contains the common service names
for each port. Creating a dictionary, we can lookup a key like ftp and return the
associated value 21 for that port.
When constructing a dictionary, each key is separated from its value by a colon,
and we separate items by commas. Notice that the method .keys() will return
a list of all keys in the dictionary and that the method .items() will return an
entire list of items in the dictionary. Next, we verify that the dictionary contains
a specific key (ftp). Referencing this key returns the value 21.