具有密钥的数据结构,作为一个单词的集合,并将其值作为一个单词或字符串 [英] a data structure with key as a cluster of words and value as a single word or string

查看:99
本文介绍了具有密钥的数据结构,作为一个单词的集合,并将其值作为一个单词或字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个数据结构,可以将一个或多个单词组映射到单个字或字符串,这可以被认为与python中的字典相反。

I want to create a data structure that is able to map a cluster or group of words to a single word or string , it can be thought as of a reverse of what a dictionary does in python .

推荐答案

您可以使用常规的dict:

You can use a regular dict:

targetword = "good"
wordmap = {
    "best": targetword,
    "positive": targetword,
    "awesome": targetword,
    "fantastic": targetword
}

这篇关于具有密钥的数据结构,作为一个单词的集合,并将其值作为一个单词或字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆