gpt4 book ai didi

Python 2to3 警告 这是什么意思?

转载 作者:太空宇宙 更新时间:2023-11-04 02:51:50 25 4
gpt4 key购买 nike

我正在使用 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 或忽略它来避免警告。

关于Python 2to3 警告 <You should use 'operator.mul(None)' here.> 这是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43614756/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com