What is a python named tuple
Editor to share with you what the python named tuple is, 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!
Description
1. NamedTuples is a lightweight, memory-efficient object type that belongs to the collection module.
2. These are dictionary-like constructs in which attribute values can be accessed through indexes, key names, or getattr () functions.
Example
Import NamedTupleclass Account (NamedTuple): name:str value: float Account (name='Naina',value=100) from input
Output
Account (name = 'Naina', value = 100.1) import defaultdict tuition from the collection _ balance = defaultdict (lambda:200) tuition _ deposit = [account (name = "Nina", value = 100.1), account (name = "Steve", value = 100.1), account (name = "Benedict" Deposit in tuition_deposits: tuition_ balances [accounts. Name] + = deposit.valueprint (dict (tuition_balances)) these are all the contents of the article "what is a named tuple of python". 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!