在 jupyter 笔记本中使用 min() 函数时出错

Getting Error while using min() funtion in jupyter notebook

我 运行 在 pycharm 和 jupyter notebook 中使用相同的代码,它在 Pycharm 中工作但导致“TypeError: 'float' object is not callable”错误运行宁在笔记本里

    lst = [-0.8952728022981113, -0.8256266449547354,
       -0.18551647265920335, -0.7845995301231219,
       0.8023977559033892, -0.9236926677953552,
       0.07240408006785382, -0.3356046029806403,
       0.7041732378587373, -0.6806752065560602,
        -0.325566685781449, -0.33240721074208945]

MINIMUM_OF_SUBLIST = round(min(lst),3)
MAXIMUM_OF_SUBLIST = round(max(lst),3)
AVERAGE_OF_SUBLIST = round(sum(lst) / len(lst),3)
print(f"Minimum: {MINIMUM_OF_SUBLIST} / Maximum: {MAXIMUM_OF_SUBLIST} / Average: {AVERAGE_OF_SUBLIST}")

当我在 pycharm 中 运行 时,它输出最小值:-0.924 / 最大值:0.802 / 平均值:-0.309

但是在笔记本中 运行ning 时出现错误:-

    TypeError                                 Traceback (most recent call last)
<ipython-input-5-638bf02333bb> in <module>
      6         -0.325566685781449, -0.33240721074208945]
      7 
----> 8 MINIMUM_OF_SUBLIST = round(min(lst),3)
      9 MAXIMUM_OF_SUBLIST = round(max(lst),3)
     10 AVERAGE_OF_SUBLIST = round(sum(lst) / len(lst),3)

TypeError: 'float' object is not callable

我不知道是什么问题(:

您似乎之前在笔记本中为 min 分配了一个值,当您尝试调用它时它现在是 float

min 是 Python 中的保留关键字,因此您应该使用 min_min_val.

之类的关键字