【发布时间】:2015-08-19 23:55:30
【问题描述】:
注意。这个问题与最初提交给 codereview 的代码有关
查看https://codereview.stackexchange.com/questions/101011/mengenlehreuhr-in-python的原始链接
所以我写了一个时钟。不只是任何时钟,这个时钟的目的是破解Kryptos section K4。
虽然应用程序的完整来源现在是on GitHub,但我遇到的具体问题与以下方法有关:
def _update(self):
self.window.erase()
self.window.box()
self.window.addstr(0, 1, str(self.index).zfill(2) + ' - ' + TimeDecipher.ciphertext[0:self.index])
self.window.addstr(1, self.cipher_offset, TimeDecipher.ciphertext[0:self.index-1], self.color)
self.window.addstr(
1,
(self.cipher_offset + self.index-1),
TimeDecipher.ciphertext[self.index-1:self.index],
self.highlight
)
self.window.addstr(1,
(self.cipher_offset + self.index),
TimeDecipher.ciphertext[self.index:],
self.color
)
self.window.addstr(2, 1, ''.join(['-' for i in range(self.width - 2)]))
for i, item in enumerate(self.lines):
self.window.addstr((i + 3), 1, str(item))
self.window.refresh()
问题描述如下。
当self.index < len(self.time_decipher.ciphertext)(97 个字符)时,突出显示按预期工作。
OBKRUOX|O|GHULBSOLIFBBWFL...
但是,当self.index == ~96 我看到这个时:
|AR|OBKRUOX...
基本上最后 2 个字符是从打印字符串的末尾剪掉并放在开头的。
请有人解释为什么会发生这种情况以及我可以做些什么来克服这个问题?
【问题讨论】:
标签: python python-curses