我对编码还很陌生,遇到了一个我无法弄清楚或找不到答案的问题。
基本上每次用户在 raw_input 中输入 yes 时,它都会吐出“if”字符串,但不排除“else”字符串。
我假设它是因为延迟干扰并且我没有正确设置它,因为在代码中它(如果,For,Else),也许 For 阻碍了代码,我不知道。将不胜感激一些帮助!:)
import sys
import time
string = 'Hello comrade, Welcome!\n'
for char in string:
sys.stdout.write(char)
sys.stdout.flush()
time.sleep(.03)
time.sleep(1)
x=raw_input('Are you ready to enter the fascinating Mists of Verocia? ')
if x == 'yes':
string = "Verocia was a mystical land located just south of Aborne"
for char in string:
sys.stdout.write(char)
sys.stdout.flush()
time.sleep(.03)
else:
print ('Please restart program whenever you are ready!')