【发布时间】:2018-01-15 18:39:01
【问题描述】:
我正在开发一个可以破译凯撒密码的程序。当我运行程序时没有输出。提前谢谢!
这是我的代码
def test():
value = input("Value here!")
with open ("cipher.*txt") as f:
nice_strings = []
for line in f:
line = line.strip()
nice_str_chars = []
for char in line:
int_of_char = ord(char)
int_of_char += value
nice_char = chr(int_of_char)
nice_str_chars.append(nice_char)
nice_str = ''.join(nice_str_chars)
nice_strings.append(nice_str)
print (line, '=>', nice_str, '\n')
return nice_strings
【问题讨论】:
-
StackOverflow 不是代码编写服务。再次发帖前请阅读help center。
-
您几乎可以肯定没有名为
cipher.*txt的文件。 -
提示:添加需要更多工作。但看来你走对了。
-
@zyflair 这是一个随机的想法:在 stackoverflow 上,以“帮助我完成作业”作为开始的问题通常被认为是错误的形式。社区通常更接受:保持简单:
here is my code, here is my input, here is my output, here is my expected output, can you help me understand why I don't get the expected output这种方法似乎得到了更多的积极关注,并导致更少的反对票。即使您正在编写的代码是为了家庭作业。 = )
标签: python python-3.x encryption