How does python call the key of a dictionary

The method of calling the key in the dictionary in python:

Use the list() method to convert the keys in the dictionary into a list, and then use the list index value to call the specified key.

# - *- coding: utf-8-*-
# Define a dictionary
dic ={'Plot':11,'crime':10,'action':8,'love':3,'comedy':2,'adventure':2,'Suspense':2,'Horror':2,'Fantasy':1}
# Convert the keys and values in the dictionary into a list through the list
keys =list(dic.keys())
values =list(dic.values())
# Result output
print("The keys list is:",end='')print(keys)print("The values list is:",end='')print(values)
# Call key in dictionary
for index inrange(len(keys)):print(keys[index])

The output is as follows:

The list of keys is: ['story','crime','action','love','comedy','adventure','suspense','thriller','fantasy']
The list of values is: [11, 10, 8, 3, 2, 2, 2, 2, 1]
Plot
crime
action
love
comedy
adventure
Suspense
Horror
Fantasy

Content expansion

Python has built-in dictionary type, uses key-value (key-value) storage, and has extremely fast search speed;

dict advantages:

Fast binary search efficiency

Store large amounts of relational data

Features: The dictionary is disordered

So far, this article on how python calls the dictionary key is introduced. For more relevant examples of python calling the dictionary key method, please search for the previous article of ZaLou.Cn or continue to browse the related articles below. Hope you will support more in the future ZaLou.Cn!

Recommended Posts

How does python call the key of a dictionary
How does python change the environment
How does python call java classes
How to find the area of a circle in python
How does python improve the calculation speed
How does python call its own function
How does Python handle the json module
How to sort a dictionary in python
How does Python call cmd using OS modules
What does the tab key in python mean
Can the value of the python dictionary be modified?
How about learning python at the age of 27?
A brief summary of the difference between Python2 and Python3
How does python get input examples from the keyboard
How to understand the introduction of packages in Python
How to understand a list of numbers in python
How does python handle the program cannot be opened
How does python judge the module installation is complete
Consolidate the foundation of Python (4)
Consolidate the foundation of Python(7)
Consolidate the foundation of Python(6)
How does Python output integers
How does python output backslashes
Consolidate the foundation of Python(5)
How does python update packages
Consolidate the foundation of Python (3)
How does python perform matrix operations
The usage of wheel in python
How Python implements the mail function
Python crawls a full set of skins for the glory of the king
Python handles the 4 wheels of Chinese
How to save the python program
Python simulation of the landlord deal
What is the use of Python
Detailed usage of dictionary in Python
A summary of 200 Python standard libraries!
How does python import dependency packages
How does python enter interactive mode
How does Python generate xml files
The premise of Python string pooling
Secrets of the new features of Python 3.8
How Python implements the timer function
How to view the python module
How does python determine prime numbers
The father of Python joins Microsoft
The operation of python access hdfs
The usage of tuples in python
End the method of running python
How to expand the ubuntu LVM partition of a VirtualBox virtual machine
Can Python implement the structure of the stack?
Learn the basics of python interactive mode
How to verify successful installation of python
What are the required parameters of python
How to make a globe with Python
Logistic regression at the bottom of python
The usage of Ajax in Python3 crawler
Python solves the Tower of Hanoi game
Which version of python does windows support
Solve the conflict of multiple versions of python
What is the scope of python variables
Python implements the sum of fractional sequences