我是编程新手。我正在尝试将数字(由用户提供)与文件中单词的数值进行匹配。示例 a=1。b=2, c=3, A=1, B=2,因此如果用户输入“2”,则输出将是列表中匹配 2 的所有单词。
userinput = raw_input("Please, enter the gematric value of the word: ")
inputfile = open('c:/school/dictionarytest.txt', 'r')
inputfile.lower()
output = []
for word in inputfile:
userinput = ord(character) - 96
output.append(character)
print output
inputfile.close()
我对此有些陌生,语法并不那么熟悉。有人可以帮忙吗?谢谢
Edit1-示例用户输入数字 7。如果单词 bad (b=2,a=1,d=4) 在列表中,则输出将是“bad”,并且任何其他匹配其字符添加的单词.