为了账号安全,请及时绑定邮箱和手机立即绑定

收到错误:TypeError:运行特定函数两次时无法调用“str”对象

收到错误:TypeError:运行特定函数两次时无法调用“str”对象

慕丝7291255 2022-06-28 17:42:37
我收到以下错误,但仅在第二次运行删除功能时:`Traceback (most recent call last):  File "English Tools.py", line 277, in <module>    English = English_Tools()  File "English Tools.py", line 100, in __init__    self.delete()TypeError: 'str' object is not callable`这是我的代码:#Importsimport osimport sysimport timeimport requestsimport configparserfrom os import pathfrom colorama import init, Foreinit()#Color Classclass color:  end = '\033[0m'  bold = '\033[1m'  underline = '\033[4m'def clear():  print("\n" * 50)#Variablesend = color.endbold = color.boldred = Fore.REDblue = Fore.BLUEcyan = Fore.CYANgreen = Fore.GREENwhite = Fore.WHITEyellow = Fore.YELLOWpurple = Fore.MAGENTAconfig = configparser.ConfigParser()title = green + bold + "English Tools"credit = green + bold + "-Made by Jackal"bad_info = red + "[+] " + yellow + color.boldgood_info = green + "[+] " + blue + color.boldbad_update = red + "[!] " + yellow + color.boldgood_update = green + "[!] " + blue + color.boldintext = blue + color.bold + ">>> " + green + endcommand_words = green + bold + "[1] " + end + white + " - " + blue + "Use logophile module" + purplecommand_read = green + bold + "[2] " + end + white + " - "  + blue + "Read your entrys" + purplecommand_delete = green + bold + "[3] " + end + white + " - "  + blue + "Reset all data" + purple我第一次可以完美地运行删除功能,但如果我尝试在同一个会话中再次运行它,它会抛出错误。有人知道怎么修这个东西吗?我可以多次运行所有其他功能,但给我带来麻烦的只是删除功能。
查看完整描述

1 回答

?
哈士奇WWW

TA贡献1799条经验 获得超6个赞

self.delete = str(input().lower())

您正在获取包含删除函数 ( self.delete) 的名称并覆盖它,将其转换为包含用户输入的字符串。到目前为止,最简单的解决方法是为该变量使用不同的名称 - 也许want_to_delete或类似的名称?


查看完整回答
反对 回复 2022-06-28
  • 1 回答
  • 0 关注
  • 102 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号