How to get all the keys and values in the dictionary

For your own notes. I haven't researched it thoroughly, so please let me know if you have any supplements or more useful ones!

List of keys [keys ()]

dictionary = {'key1': [645, 469], 'key2': "value", 'key3': 3}
print (dictionary.keys())

List of values [values ()]

dictionary = {'key1': [645, 469], 'key2': "value", 'key3': 3}
print (dictionary.values())

Get key and value at the same time [items]

A list of key and value tuples will be returned.

dictionary = {'key1': [645, 469], 'key2': "value", 'key3': 3}
print (dictionary.items())

    #-> [('key3', 3), ('key2', 'value'), ('key1', [645, 469])]

iteritems() It may be more convenient to use this method if you use a for statement.

dictionary = {'key1': [645, 469], 'key2': "value", 'key3': 3}

for key, value in dictionary.iteritems():
	print "key:", key, "-- value:", value 

Recommended Posts

How to get all the keys and values in the dictionary
How to get all the possible values in a regular expression
How to get the files in the [Python] folder
How to get the date and time difference in seconds with python
How to get the variable name itself in python
[Python] How to output the list values in order
How to get RGB and HSV histograms in OpenCV
How to get the Python version
[Shell] How to get the remote default branch in Git
How to turn the for statement when there are multiple values for one key in the dictionary
How to get and set the NTP server name by DHCP
How to get followers and followers from python using the Mastodon API
[Python] How to get the first and last days of the month
How to use the asterisk (*) in Python. Maybe this is all? ..
How to check the memory size of a dictionary in Python
How to get the vertex coordinates of a feature in ArcPy
How to display bytes in the same way in Java and Python
Python> dictionary> values ()> Get All Values by Using values ()
Get the top nth values in Pandas
How to get colored output to the console
How to handle consecutive values in MySQL
How to use is and == in Python
[Python Kivy] How to get the file path by dragging and dropping
How to write the correct shebang in Perl, Python and Ruby scripts
How to get a specific column name and index name in pandas DataFrame
Sample code to get the Twitter API oauth_token and oauth_token_secret in Python 2.7
How to use the C library in Python
How to generate permutations in Python and C ++
How to get results from id in Celery
Get multiple maximum keys in Python dictionary type
How to get help in an interactive shell
How to get dictionary type elements of Python 2.7
How to write async and await in Vue.js
Use pygogo to get the log in json.
Method to get all keys of nested dict
How to plot autocorrelation and partial autocorrelation in python
Function to extract the maximum and minimum values ​​in a slice with Go
I want to visualize where and how many people are in the factory
How to pass the path to the library built with pyenv and virtualenv in PyCharm
How to get the notebook name you are currently using in Google Colab
How to read all the classes contained in * .py in the directory specified by Python
How to count the number of elements in Django and output to a template
I'm addicted to the difference in how Flask and Django receive JSON data
I want to get the file name, line number, and function name in Python 3.4
[Python Tips] How to retrieve multiple keys with the maximum value from the dictionary
The first step to log analysis (how to format and put log data in Pandas)
How to get a list of files in the same directory with python
[AWS S3] Confirmation of the existence of folders on S3
Think about the next generation of Rack and WSGI
[python] plot the values ​​before and after the conversion of yeojohnson conversion
How to get all the keys and values in the dictionary
How to use dictionary {}
[Python] How to remove duplicate values from the list
How to retrieve the nth largest value in Python
How to run the Ansible module added in Ansible Tower
How to get multiple model objects randomly in Django
How to define Decorator and Decomaker in one function
How to use the grep command and frequent samples
How to use the exists clause in Django's queryset
[Introduction to Udemy Python3 + Application] 27. How to use the dictionary
How to use argparse and the difference between optparse
How to use the model learned in Lobe in Python
How to use Decorator in Django and how to make it
How to store Python function in Value of dictionary (dict) and call function according to Key