[英]How to fix TypeError: 'str' object is not callable?
Try to simplfy the my question here, so used a,b, & c instead.尝试在这里简化我的问题,所以改用 a,b, & c。
Even though I copied the tutorial's answer and run it through Colaboratoy, it still show TypeError:'str' object is not callable.即使我复制了教程的答案并通过 Colaboratoy 运行它,它仍然显示 TypeError:'str' object is not callable。
Why is that?这是为什么?
Thank you.谢谢你。
you might somewhere have declared the print as a variable.您可能在某个地方将 print 声明为变量。 eg:
print = "sample"
.例如:
print = "sample"
。 So restart the session or execute del print
command and try executing your code.因此,重新启动 session 或执行
del print
命令并尝试执行您的代码。
del print
a=1
b=2
c=a+b
print(c)
Try executing the above code, also follow the below rules while naming a variable in python.尝试执行上面的代码,在 python 中命名变量时也遵循以下规则。
Here are some examples of valid and invalid identifier names in Python:以下是 Python 中有效和无效标识符名称的一些示例:
# Valid identifier names
_private
_private123
myVariable
myVariable123
MY_CONSTANT
# Invalid identifier names
123invalid # cannot start with a digit
for # for is a reserved word
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.