私信  •  关注

Gareth Simpson

Gareth Simpson 最近创建的主题
Gareth Simpson 最近回复了
14 年前
回复了 Gareth Simpson 创建的主题 » 使用python检查单词

refdict中的单词是键还是值?

您的代码将只看到密钥:例如:

refDict = { 'w':'x', 'y':'z' }
for word in [ 'w','x','y','z' ]:
  if word not in refDict:
  print word

印刷品:

x
z

你想要什么;

如果单词不在refdict.values()中

当然,这相当于假设您的字典是一个实际的python字典,这似乎是一种存储单词列表的奇怪方式。