我用Python编写这个脚本已经有一段时间了。然而,我遇到了一个问题: 在我的代码中,用户键入一个命令并显示一些文本(有点像MS-DOS),但我不知道如何让它回到问题上来。(节目刚刚结束。)
以下是我的脚本示例:
command=raw_input("j;/")
command1="help"
command2="jver"
if command==command1:
print "List of commands"
print""
print""
print"help = shows all commands"
print ""
print "jver = Version of MS-Josh"
#Code here so that it goes back to the j;/ raw_input question.
elif command==command2:
print "MS-Josh version 3.12."
print ""
print "memory used: 7,117 bytes"
print "memory on computer: 1,434,078 bytes"
print "memory free: 1,426,961"
#Code here so that it goes back to the j;/ raw_input question.
else:
print "incorrect command"
使用迭代循环您的命令,并给用户退出的方式
也许你想要:
如果您将语句放在脚本的顶部,这将使您回到顶部。你知道吗
像这样:
相关问题 更多 >
编程相关推荐