namedtuple:预期 1 个参数,得到 3 个
namedtuple: expected 1 argument, got 3
我有这个基本的命名元组:
from collections import namedtuple
DBInfos = namedtuple('dbname', 'dbpath', 'dbfile')
当我尝试用
实例化一个时
d = DBInfos._make(['test', 'a/b/c', '.index.db'])
我收到以下错误:
Traceback (most recent call last):
File "./test.py", line 5, in <module>
d = DBInfos._make(['test', 'a/b/c', '.index.db'])
File "<string>", line 21, in _make
TypeError: Expected 1 arguments, got 3
但我不知道为什么:/
您对 namedtuple
函数的调用不正确。应该是:
DBInfos = namedtuple('DBInfos', ['dbname', 'dbpath', 'dbfile'])
参见:https://docs.python.org/2.7/library/collections.html#collections.namedtuple
我有这个基本的命名元组:
from collections import namedtuple
DBInfos = namedtuple('dbname', 'dbpath', 'dbfile')
当我尝试用
实例化一个时d = DBInfos._make(['test', 'a/b/c', '.index.db'])
我收到以下错误:
Traceback (most recent call last):
File "./test.py", line 5, in <module>
d = DBInfos._make(['test', 'a/b/c', '.index.db'])
File "<string>", line 21, in _make
TypeError: Expected 1 arguments, got 3
但我不知道为什么:/
您对 namedtuple
函数的调用不正确。应该是:
DBInfos = namedtuple('DBInfos', ['dbname', 'dbpath', 'dbfile'])
参见:https://docs.python.org/2.7/library/collections.html#collections.namedtuple