Python 프로그램에 약간의 문제가 있습니다. 그것은 "stats"와 같은 명령을 입력 할 수 있고 "Weather :", "Day :", "Temperature :"를 반환하거나 "day"명령을 입력하여 하루를 설정하고 "weather"를 설정하는 정말 간단한 프로그램입니다 날씨, 그래서 당신은 "통계"에서 볼 수 있습니다. 모든 명령의 끝에서 "명령 입력"이 다시 나타나야합니다. 첫 번째 명령을 입력하면 명령이 successfuly로 나타나고 "명령 입력"이 다시 나타납니다 (다른 명령을 다시 입력하면 입력 한 내용이 인쇄되고 명령이 실행되지 않고 파이썬 컴파일러가 닫힙니다).Python 프로그램에서 오류가 발생했습니다.
temp = "";
wea = "";
day = "";
input1 = input("What do you want: ");
if input1 == "stats":
print ("Day: " + day)
print ("Temperature: " + temp);
print ("Weather: " + wea);
input1 = input("What do you want: ");
elif input1 == "day":
input2 = input("Set a day: ");
day=input2;
input1 = input("What do you want: ");
elif input1 == "weather":
input3 = input("Set the weather: ");
wea=input3;
input1 = input("What do you want: ");
elif input1 == "temperature":
input4 = input("Set the temperature: ");
temp=input4;
input1 = input("What do you want: ");
elif input1 == "commands":
print ("Commands: ");
print ("day");
print ("weather");
print ("temperature");
input1 = input("What do you want: ");
else:
print ("Unknow Command! Try the commmand \"commands\".");
input1 = input("What do you want: ");
코드의 초기 라인을 다시 실행됩니다 통제 구조가 없습니다. 루프를 들여다 보면 while 루프가됩니다. –
반복 할 수 있도록 코드를 루프에 넣어야하는 것처럼 보입니다. 예 : while (input1! = "exit") : ... –