如何删除带有诅咒的文本到行尾

2024-09-28 13:02:08 发布

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

如何删除文字到行尾?在

stdscr.addstr(5, 5, "Egestas Curabitur Phasellus magnis")

结果屏幕:Egestas Curabitur Phasellus magnis\OK

^{pr2}$

结果屏幕:Elit metusrabitur Phasellus magnis问题


Tags: 屏幕ok文字行尾elitpr2stdscraddstr
3条回答

要删除到下线(行尾),请使用^{}

示例:

import curses

window = curses.initscr()
window.clrtoeol()
window.refresh()

但是,我真的推荐在任何控制台/TUI编程中使用伟大的urwid

更新:Bhargav-Rao是对的;您必须显式地调用window.refresh()

Accordingly, curses requires that you explicitly tell it to redraw windows, using the refresh() method of window objects. In practice, this doesn’t really complicate programming with curses much. Most programs go into a flurry of activity, and then pause waiting for a keypress or some other action on the part of the user. All you have to do is to be sure that the screen has been redrawn before pausing to wait for user input, by simply calling stdscr.refresh() or the refresh() method of some other relevant window.

您需要在第二行代码之前调用stdscr.refresh()。这一点在documentation中已经明确了

All you have to do is to be sure that the screen has been redrawn before pausing to wait for user input, by simply calling stdscr.refresh()

stdscr.addstr(5, 5, "Elit metus")之前使用stdscr.refresh()。它会起作用的。在

相关问题 更多 >

    热门问题