Python:命名为元组._source在python 3.7中不起作用

问题描述 投票:0回答:1

我已经尝试过使用此代码

from collections import namedtuple
t = namedtuple('t', 'a b c')
i = t(1,2,3)
print(i._source, t._source)

但是当我运行它时,它说没有属性_source(对于t来说,因此对于i来说)。从3.6开始是否被淘汰?

python collections attributes namedtuple
1个回答
0
投票

是,如here所述,属性_source已从Python 3.7中的命名元组中删除。

在版本3.7中更改:删除详细参数和_source属性。

© www.soinside.com 2019 - 2024. All rights reserved.