首页 > 解决方案 > 为什么我的语法是错误的?(TypeError:“元组”对象不可调用)

问题描述

我的语法是这样的

print ("Hello!")
print ("Ayah berkata, \"Semangat\"")
print ("Ayah berkata,", end=" ")
print ("\"Semangat\"")

我的输出是这样的

TypeError                                 Traceback (most recent call last)
<ipython-input-8-122075a697db> in <module>()
----> 1 print ("Hello!")
      2 print ("Ayah berkata, \"Semangat\"")
      3 print ("Ayah berkata,", end=" ")
      4 print ("\"Semangat\"")

TypeError: 'tuple' object is not callable

我是 google colab 的代码

标签: tuplestypeerror

解决方案


您创建了一个名为“print”的变量,它是一个元组。您必须删除或重命名变量“print”。

>>> print = ("test", "test") # <- somewhere there might be a linge likethis one
>>> print ("Anything")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'tuple' object is not callable

推荐阅读