我在英语学习上有困难。 我只能把它从英语翻译成英语。 我想要的是如果这个词是英语翻译成Tuccin, 如果单词是Tuccin,请翻译成英语完整短语。 最后,如果有任何输入字没有存储,我想要它 把同一个词印在自己的地方,这样就可以证明 没什么好翻译的
#Translator.py
Tuc={"i":["o"],"love":["wau"],"you":["uo"],"me":["ye"],"my":["yem"],
"mine":["yeme"],"are":["sia"]}
phrase=True
reverseLookup = False
while True:
reverseLookup = False
translation = str(raw_input("Enter content for translation.\n").lower())
input_list = translation.split()
#English to Tuccin
if phrase ==True:
print "*English Detected!"
for word in input_list:
if word in Tuc:
print ("".join(Tuc[word]))
else:
reverseLookup = True
#Tuccin to english
elif phrase == True and reverseLookup == True:
print "*Tuccin Detected!"
input_list = translation.split()
for k, v in Tuc.iteritems():
if translation in v:
print k
else:
print "Word Not Stored!"
reverseLookup = False
print word
Thisstack answer演示如何快速反转简单字典。所以,在你的情况下,你要做的是:
用这本字典的方法和你用Tuc字典的方法一样
如果您的Tuc字典没有冗余的列表作为值,则会更容易:
相关问题 更多 >
编程相关推荐