无法附加到 curses 模块的列表中?

not able to append in a list in curses module?

我想用 python curses 模块获取用户输入,但每次它都没有在列表中添加任何元素,谁能帮帮我

我的代码:-

import curses
from curses import wrapper
from curses.textpad import Textbox, rectangle

tempo_list = []


def main(stdscr, text="hello"):
    final_text = text + " (hit Ctrl-G to send)"
    for i in range(5):
        stdscr.addstr(0, 0, final_text)
        win = curses.newwin(1, 21, 2, 1)
        box = Textbox(win)
        rectangle(stdscr, 1, 0, 3, 23)
        stdscr.refresh()
        box.edit()
        val = box.gather().replace("\n", "")
        tempo_list.append(val)


print(tempo_list)

wrapper(main)

您在打印(空)列表后wrapper(main)调用。更改语句的顺序。