我使用的是python2.6,我想知道如何从控制台使用up键。 我现在不想使用Tkinter或其他GUI库。你知道吗
下面是我的代码。你知道吗
history=[]
while(1):
try:
cmd = self.get_cmd()
history.append(cmd) # append user command
# if i press UP key, just display history.
# i'll you for statement to disaply history.
print "%s" %history
对于您的目标,您可以查看readline模块,它是为历史处理之类的事情而设计的。它是标准的python库,所以可以满足您的需要。对于其他模块,rlcompleter您甚至可以处理自动完成。你知道吗
相关问题 更多 >
编程相关推荐