首页 > 解决方案 > 名称 Bot 未在 cicle 中定义,而

问题描述

我试图在一个类中创建一个 cicle 以创建一个“无限”循环,当我将“test” istance 与“print”方法相关联时,出现错误“name 'bot' is not defined”。我该如何解决?

这里的代码:

class bot:

  while(1):
    test = bot()
    def print():
        print = "Hello"
        return print
    test = bot()
    print(test.print())

感谢您

标签: pythonpython-3.x

解决方案


推荐阅读