我正在使用 2to3 转换脚本。我得到的唯一警告是:
RefactoringTool: Line 716: You should use 'operator.mul(None)' here.
原始脚本的第 716 行是:
classes = repeat(None)
我不知道我应该在哪里使用 operator.mul(None)。 repeat() ( link to docs ) 的引用文档显示我可以毫无问题地通过 None。那么,我该怎么办呢?
请您参考如下方法:
2to3 对您指的是哪个 repeat 感到困惑。它认为您在 Python 2 中使用 operator.repeat:
Help on built-in function repeat in module operator:
repeat(...)
repeat(a, b) -- Return a * b, where a is a sequence, and b is an integer.
代替 itertools.repeat。老实说,这不是一个很好的猜测,因为 operator.repeat 有两个参数,但这就是它的猜测。您可以看到 the docs 中列出的转换.
您可以使用完全限定的 itertools.repeat 或忽略它来避免警告。
