本文整理汇总了Python中dictionary.Dictionary.get_dict方法的典型用法代码示例。如果您正苦于以下问题:Python Dictionary.get_dict方法的具体用法?Python Dictionary.get_dict怎么用?Python Dictionary.get_dict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dictionary.Dictionary
的用法示例。
在下文中一共展示了Dictionary.get_dict方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Anagram
# 需要导入模块: from dictionary import Dictionary [as 别名]
# 或者: from dictionary.Dictionary import get_dict [as 别名]
class Anagram(object):
def __init__(self):
self.possible_words = set()
self.output = set()
self.dict = Dictionary()
fich = open('Unabr.dict', 'r')
self.dict.get_dict(fich)
fich.close()
def set_input(self, string):
self.string = string
def get_output(self):
self.process('', list(self.string))
for word in self.possible_words:
if self.dict.is_in_dict(word):
self.output.add(word)
return self.output
def process(self, string, l):
if len(l) == 0:
self.possible_words.add(string)
return
for index in range(len(l)):
new_list = l[:]
elem = new_list.pop(index)
self.process(string + elem, new_list)
示例2: Dictionary
# 需要导入模块: from dictionary import Dictionary [as 别名]
# 或者: from dictionary.Dictionary import get_dict [as 别名]
"""
FINISHED_TEMPLATE = u"""
<br/>
<pre>
{message}
{definition}
</pre>
"""
# Load the dictionary
dictionary = Dictionary()
# Only use good words
valid_words = [k for k in dictionary.get_dict() if re.match('^[a-zA-Z]{4,20}$', k)]
class Hangman(object):
def __init__(self):
# Game variables
self.state = 'NOT_PLAYING'
self.word = None
self.word_revealed = None
self.guesses_right = None
self.guesses_wrong = None
def new_game(self):
"""
Start a new game of hangman
"""
if self.state == 'PLAYING':