Python-api: collections——High-performance container datatypes
2017-08-23 10:18
363 查看
Python-api: collections——High-performance container datatypes
Python-api collectionsHigh-performance container datatypesnamedtuple
来源:https://docs.python.org/2/library/collections.html
一点一点更新,用到一点更新一点
namedtuple
namedtuple主要是为了增加tuple的可读性,它可以用于一系列比较规整的tuple,并且namedtuple可以通过名称去索引而tuple只能通过下标去索引Person = namedtuple('Person', 'name age gender') print(type(Person)) Bob = Person(name = 'Bob', age = 29, gender = 'female') print(Bob.name) print(Bob)
namedtuple默认是不能用关键字的,如果出现类似class,def等关键字会报错,可以通过rename参数来解决这个问题:
#rename = true 可以考虑到Python关键字 Person = namedtuple('Person', 'name class gender', rename = true)
相关文章推荐
- [Python] collections — High-performance container datatypes
- 8.3. collections — High-performance container datatypes — Python v2.7.3 documentation
- Dynamics CRM2016 Set Values of all Data Types using Web API
- 二、Python Data Types
- Enabling High Performance Data Transfers
- Dynamics CRM2016 Set Values of all Data Types using Web API
- Lesson 3.1 - Python Core Data Types
- Dynamics CRM2016 Set Values of all Data Types using Web API
- Slow performance occurs when you copy data to a TCP server by using a Windows Sockets API program
- Dynamics CRM2016 Set Values of all Data Types using Web API
- Enabling High Performance Data Transfers
- Python - Datatypes : Dictionaries
- Enabling High Performance Data Transfers
- Enabling High Performance Data Transfers
- Translating lotus API Data Types to LotusScript
- python basics - Datatypes Collections and Lists
- II. Data types in the Win32 API
- View and Data API Tips: Constrain Viewer Within a div Container
- Java vs. Python (2): Data Types
- How to Build a High-Performance Data Warehouse (简译)