打印语句给出不可调用的错误

时间:2018-07-10 13:15:10

标签: python callable

print = ('Tell me about your pet. ')
about_pet = input()

if 'dog'.lower() in about_pet == True :
    print('ah, a dog')
if 'cat'.lower() in about_pet == True :
    print ('ooh, a kitty')

print ('Thanks for the story')

当我运行这段代码时,我得到一个错误:

str对象不可调用

这是什么原因造成的?

1 个答案:

答案 0 :(得分:3)

print = ('Tell me about your pet. ')作为字符串覆盖函数print。之后,它不再是一个函数,因此,任何以后尝试将其作为函数调用时,都会出错。

摆脱=,因此您无需更改print是什么。

相关问题