我有一个程序可以要求用户对现有词典进行分类: 这是我的字典:
>>> print Vocab_World
{'excelent': 'awesome', 'quit': 'exit', 'great': 'good', 'ceken':
'bilir', 'tremendous': 'fabolous', 'gurbet': 'hasret', 'postpone':
'put_offt', 'ozlem': 'hasret'}
现在,我想问用户是否要将与嵌套字典相同的有意义的单词分类,我想为分类的单词创建一个如下所示的列表
{'Adverb' : {'excelent': 'awesome','great': 'good','tremendous': 'fabolous'} }
是的。你知道吗
categorized_words = raw_input("Please select the words that you want to categorize")
new_category = raw_input("Please input the new category name ")
categorized_World=Vocab_World[new_category][0][categorized_words]
有没有一种方法可以根据用户的输入动态地实现这一点?你知道吗
运行并输入:
将返回:
这应该做到:
输出为:
相关问题 更多 >
编程相关推荐