【问题标题】:"Int object is not callable"\"Int 对象不可调用\"
【发布时间】:2022-11-28 10:40:00
【问题描述】:
num =  int(input("enter num ")) 
if num <=0:
   output= abs(num)   
   print(output)  
else:
   output =abs(num)   
   print(output)
TypeError                                 Traceback (most recent call last)
<ipython-input-54-aba2c4ff0eb3> in <module>
      3 INPUT: -1        OUTPUT: 1"""
      4 
----> 5 num =  int(input("enter num "))
      6 
      7 

TypeError: 'int' object is not callable

【问题讨论】:

  • 您的错误无法从您的代码中重现。如果您在 Jupyter notebook 中工作或在控制台中键入命令,请确保执行环境的干净重启。您可能为变量 int 分配了一个数字,因此覆盖了 int 函数本身。

标签: python


【解决方案1】:
num = int(input("enter num ")) 

output = abs(num)   
print(output) 

【讨论】:

    猜你喜欢
    • 2015-01-29
    • 2014-03-17
    • 1970-01-01
    • 2015-12-19
    • 2017-09-19
    • 2012-04-03
    相关资源
    最近更新 更多