Get the App
SLTechnology News&Howtos  ›  Development  › 

How python maps objects to unique counting numbers

Shulou Source: shulou.com Published: 2022-06-01 04:49:36 09月22日 Update

Editor to share with you how python maps objects to unique counting numbers, 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!

Map objects to a unique count number (collections.defaultdict)

> > import itertools, collections > value_to_numeric_map = collections.defaultdict (itertools.count () next) > value_to_numeric_map ["a"] 0 > value_to_numeric_map ["b"] 1 > > value_to_numeric_map ["c"] 2 > value_to_numeric_map ["a"] 0 > value_to_numeric_map ["b"] 1 is all the contents of this article "how python maps objects to unique counting numbers". 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: Objects numbers articles content not much most more knowledge industry information information channels channels references learning help Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Shulou Technology Huawei Linux Shulou Tech Info