我该如何让我的Python脚本等待用户按下任意键?
sys.stdin.readline()
os.system
似乎总是调用 sh
,而后者不认识 read 命令的 s 和 n 选项。不过可以将 read 命令传递给 bash:
os.system("""bash -c 'read -s -n 1 -p "Press any key to continue..."'""")
while True:
choice = raw_input("> ")
if choice == 'b' :
print "You win"
input("yay")
break