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

Python运行报TypeError: 'list' object is not callable如何修复

问题原因

你在代码中重写了Python内置的input()函数标识符:

  • 第一次循环执行input = input1.split()时,原本指向内置输入函数的input被赋值为split()返回的列表对象
  • 第二次循环执行input1 = input("Hello >> ")时,程序尝试将列表对象作为函数调用,触发类型错误

解决方案

将自定义变量修改为不与内置函数重名的名称即可,示例修改后代码如下:

while True:
    input1 = input("Hello >> ")

    # 把变量名从input改成其他不冲突的名称即可
    input_cmd = input1.split()

    if input_cmd[0] == "Sup":
        print("HI!")

注意事项

日常编码时不要使用Python内置的函数名、类型名、关键字作为自定义变量名,比如str、int、list、dict、print等,都可能引发同类报错。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.02 13:36:05