내 코드의 변수에 문제가 있습니다. 여기에 내 코드의 일부는 다음과 같습니다Python - 부동 변수가 항상 가장 큰 것으로 반환됩니다.
import re
name = raw_input("Input the Character's name: ")
name = name.lower()
season = raw_input("Input the season: ")
rainyday = raw_input("Is it a rainy day? ")
total_time = raw_input("What time is it?(Input as e.g 1.30 am")
non_decimal = re.compile(r'[^\d.]+')
timel = non_decimal.sub('', total_time)
float(timel)
print timel
#ALEX
if name == "alex":
if rainyday == "yes":
if "am" in total_time:
if time > 8.00:
print("He's in the entryway of his house until 1:00 PM")
else:
print("He's in his room until 8:00 AM")
print("!")
elif timel < 1:
print("He's in the entryway of his room until 1:00 PM")
print("y")
elif timel < 4.2:
print("He's leaving his room to go to the dog pen until 6:30 PM")
elif timel < 6.3:
print("He's at the dog pen until 6:30")
elif timel < 8.0:
print("He's in the entryway of his house until 8:00 P.M")
elif timel < 10.0:
print("He's standing by the dresser in his room")
else:
print("He's sleeping")
때마다 그것으로, 내가, 내가 쉘에서 실행 코드의 이 라인이 보여 "그는 자고"else 문을 얻을 "시"와 숫자로 I 입력 TOTAL_TIME 내 문제는 :
>>> print timel
2
>>> timel < 3
False
>>> 2 < 3
True
>>> timel < 1000000000
False
그 timel는 항상 정의 된 경우에도, 다른 모든 것들보다 더 큰 정의되지 않은 번호입니다 보인다. 이 문제에 대한 도움을 크게 주시면 감사하겠습니다.
을 변환
timel = float(timel)
을해야한다 또는', 마지막 줄 '수 timel = 플로트 (timel) – zvone