简单Python代码中的意外关键字参数,为什么?

时间:2014-09-18 19:41:13

标签: python keyword-argument

我试图使用pymarc MARCReader库类。我的python代码在这行窒息:

reader = MARCReader(file(input), to_unicode=True)

带有消息:

Traceback (most recent call last):
  File "convert_bib.py", line 10, in <module>
    reader = MARCReader(file(input), to_unicode=True)
TypeError: __init__() got an unexpected keyword argument 'to_unicode'

从pymarc 3.0.1的源代码我复制了下面的构造函数语法:

class MARCReader(Reader):
<snip>
    def __init__(self, marc_target, to_unicode=True, force_utf8=False,
            hide_utf8_warnings=False, utf8_handling='strict'):
    <snip>

在我看来,我的代码是正确的。我想我不能很好地理解关键字参数,因为我无法弄清楚出了什么问题。

0 个答案:

没有答案