Get the App
SLTechnology News&Howtos  ›  Development  › 

How python uses popitem () to delete dictionary key-value pairs

Shulou Source: shulou.com Published: 2022-06-01 03:06:00 10月05日 Update

Editor to share with you how python uses popitem () to delete the dictionary key value pair, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Popitem () deletes dictionary key-value pairs

Popitem () deletes the dictionary key-value pair, deletes it according to the last set of key-value pairs, and returns the meta-ancestor composed of the deleted key-value pair.

Dict4 = {'name':' Tom', 'age': 18} res = dict4.popitem () print (dict4, res)

{'name':' Tom'} ('age', 18)

The above is all the content of the article "how python uses popitem () to delete dictionary key-value pairs". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Dictionaries articles content not much most more knowledge industry information channels channels Yuanzu reference learning help Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Linux macOS Redmi Huawei