【问题标题】:"'str' object is not callable" when try to run input function in google colaboratory尝试在 google colaboratory 中运行输入函数时出现“'str' 对象不可调用”
【发布时间】:2021-09-06 10:51:33
【问题描述】:

我试图运行这段代码,但我没有发现我的代码有任何问题,但谷歌合作实验室称它为错误

这是代码:

start = int(input("Start : "))
end = int(input("End :"))
for i in range (start, end+1):
  print(i)

错误信息:

    TypeError                                 Traceback (most recent call last)
<ipython-input-3-bc333f731d78> in <module>()
----> 1 start = int(input("Start : "))
      2 end = int(input("End :"))
      3 for i in range (start, end+1):
      4   print(i)

TypeError: 'str' object is not callable

【问题讨论】:

    标签: python google-colaboratory


    【解决方案1】:

    我猜,在你的代码中,你确实做到了:

    int = "..."
    

    或:

    input = "..."
    

    因此替换了内置函数

    【讨论】:

    • 感谢您的回答,我已经更改了变量,但有时 google colab 仍然称其为错误。是否有效地重新启动运行时来解决问题?对不起我的英语不好
    • @user16838812 然后请使用完整代码和完整回溯更新您的问题
    • 代码已经正常运行,感谢帮助,抱歉回复晚了
    猜你喜欢
    • 2020-10-19
    • 1970-01-01
    • 2016-03-21
    • 2020-09-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-11
    相关资源
    最近更新 更多