[英]Getting error while using watson_developer_cloud in Jupyter Notebook
[英]Getting Error while using min() funtion in jupyter notebook
我在 pycharm 和 jupyter notebook 中運行相同的代碼,它在 Pycharm 中運行但在 notebook 中運行時導致“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
但是在筆記本中運行時出現錯誤:-
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
類的東西。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.