我试图首先使用raw_input()函数,但发现它与ncurses兼容.
然后我尝试了window.getch()功能,我可以在屏幕上输入和显示字符,但无法实现输入.我如何输入一个单词ncurses并可以使用if语句来评估它?
例如,我想知道这一点ncurses:
import ncurses
stdscr = curses.initscr()
# ???_input = "cool" # this is the missing input method I want to know
if ???_input == "cool":
stdscr.addstr(1,1,"Super cool!")
stdscr.refresh()
stdscr.getch()
curses.endwin()
Run Code Online (Sandbox Code Playgroud) 如果我想在python文本之间添加一些输入,如何在用户输入内容并按Enter键之后切换到新行而又不这样做呢?
例如:
print "I have"
h = input()
print "apples and"
h1 = input()
print "pears."
Run Code Online (Sandbox Code Playgroud)
应该修改为在一行输出到控制台,说:
I have h apples and h1 pears.
Run Code Online (Sandbox Code Playgroud)
应该将其放在一行上这一事实没有更深的目的,这是假设的,我希望它看起来像那样。