无法在诅咒模块中的列表中附加吗?

发布于 2025-01-27 03:21:15 字数 750 浏览 3 评论 0原文

我想用Python诅咒模块进行用户输入,但是每次不添加列表中的任何元素时,请帮助我 “这是输出”

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)

I want to take a user input with python curses module but every time it is not adding any element in the list can any one please help mehere is the output

my code :-

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)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

在梵高的星空下 2025-02-03 03:21:15

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

You call wrapper(main) after you print the (empty) list. Change the order of the statements.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文