带有单词列表的 Gematria
我是编程新手。我试图将一个数字(由用户给出)与文件中单词的数值进行匹配。示例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()
我对此有点陌生,语法不是那个熟悉的。有人可以帮忙吗?谢谢
编辑1-示例用户输入数字 7。如果单词 bad (b=2,a=1,d=4) 位于列表中,则输出将为“bad”,并且与添加的任何其他单词相匹配他们的性格。
I am new at programming. I am trying to match a number (given by the user) to the numeric values of words in a file. Example a=1. b=2, c=3, A=1, B=2, so that if the user enters "2" then the output would be all words in the list that match 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()
I am somewhat new at this and the syntax is not that familiar. Could someone please help? Thank you
Edit1- example the user enters the number 7. If the word bad (b=2,a=1,d=4) is on the list the output would be "bad", and any other words that match the addition of their characters.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
下面是带有详细描述的注释的代码:
其中
gematric_value()
函数是:注意:不要在代码中使用上述注释样式。仅出于教育目的才可以接受。您应该假设您的代码的读者熟悉 Python。
Here's the code with comments that describe it in detail:
Where
gematric_value()
function is:Note: don't use the above comment style in your code. It is acceptable only for educational purposes. You should assume that a reader of your code is familiar with Python.
您没有读取该文件
You are not reading the file