小编use*_*333的帖子

阿诺德/书密码与Python

我正在尝试写一本密码解码器,以下是我到目前为止所得到的。

code = open("code.txt", "r").read() 
my_book = open("book.txt", "r").read() 
book = my_book.txt 
code_line = 0 
while code_line < 6 :
      sl = code.split('\n')[code_line]+'\n'
      paragraph_num = sl.split(' ')[0]
      line_num =  sl.split(' ')[1]
      word_num = sl.split(' ')[2]
      x = x+1
Run Code Online (Sandbox Code Playgroud)

循环更改以下变量:

  • 段落
  • 线
  • 单词

一切都运转良好。

但我现在需要的是如何指定段落,然后指定行,然后在 while 循环中指定 for 循环这个词将完美地工作。

所以我想从段落号“paragraph_num”和行号“line_num”中获取字号“word_num”

这是我的代码文件,我正在尝试将其转换为单词

“段落号”、“行号”、“字数”

70 1 3
50 2 2
21 2 9
28 1 6
71 2 2
27 1 4
Run Code Online (Sandbox Code Playgroud)

然后我希望我的输出看起来像这样

word1
word2  
word3
word4 
word5 
word6
Run Code Online (Sandbox Code Playgroud)

顺便说一下,我的书“我需要从中获取文字的文件”看起来像这样

单词1 单词2 单词3 …

python encryption decode cpu-word paragraph

5
推荐指数
1
解决办法
2237
查看次数

标签 统计

cpu-word ×1

decode ×1

encryption ×1

paragraph ×1

python ×1