In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article is about how the underlying implementation of python dictionary types is implemented. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
1. The underlying dictionary type is based on a hash table.
2. The data types of keys in the dictionary must be static data types, such as simple data types, strings, and tuples. Dictionary types are data structures based on hash tables.
Example
#-*-coding: utf-8-*-"@ Time: 2021-8-14 21:04@Author: LYP@FileName: dic_Python.py@SoftWare: PyCharm" dict2 = {'abc': 123,98.6: 37} scores = {' Mathematics': 95, 'English': 92, 'Chinese': 84, 'Chemistry': 90, 'Biology': 91 Physics: 80} dic= {} dic [1] = 'hello'dic [2] =' world'#print (dic) # print (dict2) # print (scores) print ("scores ['Mathematics]:", scores [' Mathematics]) print ("scores ['English]:", scores [' English]) print ("scores [Chemistry]:", scores.get ("Chemistry") print ("scores ['Biology]:" Scores.get ('biology') print (scores) for key,value in scores.items (): print (key, "- >", value) print ("add values to the dictionary") scores ['history'] = 80print (scores) scores.setdefault ('geography') 89) print (scores) print ("Delete elements") del scores ['Geography'] print (scores) scores.pop ('History') print (scores) # scores.clear () # print (scores) print ("modify value") print (scores) scores ['Mathematics'] = 100print (scores) print ("determine whether a key-value pair is included in a dictionary") print ("whether scores includes mathematics", "Mathematics'in scores) print (" whether geography is included in scores " Geographic in scores) print ("whether history is included in scores", "history" not in scores) print (scores.keys ()) print (scores.values ()) print (scores.items ()) Thank you for reading! This is the end of this article on "how to realize the bottom of python dictionary type". I hope the above content can be helpful to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.