def __init__(self):
#self.data = []
self.random_word = random.choice(open("EnglishDictionary.txt").readlines()).strip()
self.length_notice = "The word you're guessing is {} letters long.".format(len(random_word))
这只是返回错误:名称 'random_word' 是不确定的在Python中,如何基于另一个__init__变量设置值?
你可以让__init__调用一个函数,并传入你生成的那个random_word。 – Raizuri