You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Python执行input = input("sussy ")时出现TypeError: 'str' object not callable错误

问题分析与解决
  • 报错原因:你误用了Python内置的input()函数名作为变量名。第一次执行input = input("alo")后,原本是函数的input被覆盖成了你输入的字符串。第二次执行input = input("sussy ")时,Python会尝试调用这个字符串,必然触发TypeError: 'str' object is not callable错误。

  • 修复方案:把存储输入内容的变量名换成非内置函数名,比如user_input。同时原代码缺少sleep模块的导入语句,不补上的话运行也会报错,修改后的完整代码如下:

from time import sleep

print("hello to the test")
sleep(2)
print("u have to guess the word")
sleep(2)
print("lets start")
sleep(2)
user_input = input("alo")
sleep(0.5)
if user_input == "ha":
    print("yes")
    sleep(0.5)
    print("u correct")
    sleep(0.9)
else:
    print("no")
    sleep(0.6)
    wrongword = "alo" + user_input
    print("u said", wrongword)
    sleep(0.5)
    print("correct was aloha")
    sleep(0.9)
print("next word")
sleep(0.5)
user_input = input("sussy ")
sleep(0.5)
if user_input == "baka":
    print("yes")
    sleep(0.5)
    print("u r correct again")
else:
    print("no")
    sleep(0.6)
    wrongword = "sussy " + user_input
    print("u said", wrongword)
    sleep(0.5)
    print("correct was sussy baka")

内容的提问来源于stack exchange,提问作者Greening Siren

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.18 07:05:17