python namedtuple命名元组

Posted hailuo

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python namedtuple命名元组相关的知识,希望对你有一定的参考价值。

from collections import namedtuple
Animal=namedtuple(\'Animal\',\'name age type\')
perry=Animal(name=\'perry\',age=1,type=\'cat\')
print(perry.type)
print(perry[0])
print(perry._asdict())

 

以上是关于python namedtuple命名元组的主要内容,如果未能解决你的问题,请参考以下文章

Python 操作Redis

python爬虫入门----- 阿里巴巴供应商爬虫

Python词典设置默认值小技巧

《python学习手册(第4版)》pdf

Django settings.py 的media路径设置

Python中的赋值,浅拷贝和深拷贝的区别