Skip to main content
 首页 » 编程设计

python之类型错误 : 'str' object is not callable for printing a dictionary inside a while loop

2025年05月04日17insus

<分区>

我在编写代码字游戏(也称为替换字符)程序时遇到问题,并且不断收到错误“str”对象不可调用。这是我的代码(只是与这本字典相关的 while 循环的一部分:

used_pairings = {} 
 
while.....: 
    used_pairings[guesschar] = guessletter 
    print = ("At this point you can decide whether to delete a character-letter pairing.") 
    used_pairings_choice = input("Type 1 to delete a pairing or ENTER to carry on: ") 
    if used_pairings_choice == "1": 
        print ("These are your pairings so far:") 
        print (used_pairings) 
    else: 
        print ("Continuing program.") 

这是我得到的错误:

"Codeword.py", line 79, in <module> 
    print ("These are your pairings so far:") 
TypeError: 'str' object not callable 

我完全不明白这意味着什么以及为什么我会收到此错误消息,因此非常感谢您的帮助。提前致谢!