我试过这个密码
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开始就被淘汰了吗?
_source
t
i
是的,如前所述 here ,属性 _source 已从中删除 namedtuples 在Python3.7中。
namedtuples
在版本3.7中更改: 移除 冗长的 参数和 _来源 属性。
_来源