cygwin - Python 2.7.2,Cygwin,raw_input : why does it only print the prompt after I give the input?

标签 cygwin python-2.7

我有这个 python 程序:

import board

theBoard = board.Board()
theBoard.setup_new_game()
theBoard.display()

inputStr = raw_input('Enter move \"x y\":')
print inputStr

Board是我写的一个类,显示黑白棋盘。当我运行这个程序时,它立即停止并等待输入。当我输入内容并按回车键时,它会显示面板并在其下方显示输入提示。

我是否需要使用诅咒之类的东西来让它正常运行,还是我只是缺少一些基本的东西?据我所知,这应该打印板,打印提示,然后等待我提供输入。

最佳答案

通常这是因为输出没有被正确刷新。有时,出于效率原因,输出驱动程序会等待实际打印文本,直到它认为需要打印文本,但有时它会导致诸如此类的问题。我不知道使用您正在使用的 API 进行刷新的确切接口(interface),但应该很容易找到。

关于cygwin - Python 2.7.2,Cygwin,raw_input : why does it only print the prompt after I give the input?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10801693/

相关文章:

c++ - 对 mmap 和 munmap 的 undefined reference

java - Win 7下无法在Cygwin中启动Marathon测试

python - 在列表列表中查找重复项

cygwin - 使用 Cygwin 监控 Windows 服务

opencv - 在Cygwin上安装Opencv

character-encoding - Cygwin 终端不显示某些编码字符

python - Python 2 中 "//"和 "/"的区别

python - 如何(正确)使用 PIP 安装和导入 pymavlink

database - 如何更新 Google App Engine NDB 对象上的数据,以便它可以同时进行多次写入

python - 将 map 结果作为键控字典返回