2

当我尝试使用“comb”功能时出现错误:

$ python
Python 3.7.1 (default, Dec 14 2018, 13:28:58) 
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import math
>>> print(math.comb(6,49))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'math' has no attribute 'comb'
>>> 
4

1 回答 1

3

comb 函数是 Python 3.8 中的新功能(请参阅此处的文档)。你的 Python 安装是 3.7.1。如果您更新 Python 安装,则该问题应该得到解决。

于 2021-04-16T08:31:49.407 回答