我正在使用curses.textpad
模块在MacBook上制作Python程序。这是我完整的代码:
import curses
from curses.textpad import Textbox, rectangle
def editor(stdscr):
stdscr.addstr(0, 0, "Type something: (hit Ctrl-G to exit)")
editor = curses.newwin(5, 30, 2, 1)
rectangle(stdscr, 1, 0, 1 + 5 + 1, 1 + 30 + 1)
stdscr.refresh()
box = Textbox(editor)
box.edit()
message = box.gather()
print(message)
text = curses.wrapper(editor)
print("Here's what you typed:")
print(text)
每当我尝试运行该错误时,都会不断出现此错误:
Traceback (most recent call last):
File "/Users/Donoru/Desktop/editor/main.py", line 17, in <module>
text = curses.wrapper(editor)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/curses/__init__.py", line 84, in wrapper
stdscr = initscr()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/curses/__init__.py", line 29, in initscr
setupterm(term=_os.environ.get("TERM", "unknown"),
_curses.error: setupterm: could not find terminal
我该如何解决?