擅长:python、mysql、java
<p>建议的答案比必要的更复杂。如果您使用<a href="http://invisible-island.net/ncurses/man/curs_window.3x.html#h3-subwin" rel="nofollow noreferrer"><strong>subwin</strong></a>,它将与原始窗口共享内存,并且将在无需额外工作的情况下重新绘制。</p>
<p>以下是修改后的原始程序(单行更改):</p>
<pre><code>import curses
screen = curses.initscr()
try:
screen.border(0)
box1 = screen.subwin(20, 20, 5, 5)
box1.box()
screen.getch()
finally:
curses.endwin()
</code></pre>