擅长:python、mysql、java
<p>有<a href="http://docs.python.org/3/library/collections.html?highlight=namedtuple#collections.namedtuple" rel="nofollow noreferrer">^{<cd1>}</a>。在</p>
<pre><code>>>> from collections import namedtuple
>>> Element = namedtuple('Element', 'name age')
>>> A.element[0] = Element('qwe', 23)
>>> print A.element[0].name
qwe
>>> print A.element[0].age
23
</code></pre>
<p>但是这些是元组,而不是列表,因此它们不能更改。而且,这些基本上仍然是类,但是您只是没有用<code>class</code>关键字来定义它们。请参见<a href="https://stackoverflow.com/a/2970722/1907098">this</a>以获得深入的解释。在</p>