我正在运行Python 3.11.5。当我在 REPL 中输入:
from itertools import batched
它返回以下输出:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'batched' from 'itertools' (unknown location)
为什么要批量执行此操作是内置模块功能。我知道 CPython 存储库存在一些问题。但是我有什么办法可以在我的系统中解决这个问题吗?
这是3.12版本中的新功能。文档说得很清楚。
有关在早期版本中执行此操作的方法,请参阅此问题及其答案。