python curses getstr的输入限制?

2024-09-30 18:35:27 发布

您现在位置:Python中文网/ 问答频道 /正文

下午好

我尝试使用curses,这个脚本的一个要求是接受大量的数据。数据是用来粘贴的,虽然通常只有几千行,但很容易就可以增长到数万行。我的问题似乎是我的输入仅限于窗口的大小?在

例如:

begin_x = 0
begin_y = 0
height = 15
width = 30
window = curses.newwin(height, width, begin_y, begin_x)

c = window.getstr()
stdscr.addstr(0, 0, str(c.count(b'a')), curses.color_pair(1))
stdscr.refresh()

当我输入尽可能多的'a'字符时,输出为449。在

有没有办法把这个提高一点?我试图将窗口设置得更大,但仍达到1024个最大值。在


Tags: 数据脚本粘贴countwindowwidthcursescolor
1条回答
网友
1楼 · 发布于 2024-09-30 18:35:27

快去救人!在

我想到的是:

d = ''

newline = 0
while newline == 0:
    c = window.getkey()
    if c == '\n':
        newline = 1
    else:
        d = d + c

d是一个字符串,c是getkey(一个1个字符的字符串)的结果如果它收到newline,quit。如果没有,继续循环直到我们得到新线。在

相关问题 更多 >