当我运行这个程序时,我收到错误,ValueError: invalid literal for int() with base 10: '',我觉得这与 int 和 str 转换有关,但我真的不太确定,感谢任何帮助:)
CalendarDict = {1:"January", 2:"February", 3:"March", 4:"April", 5:"May",
6:"June", 7:"July", 8:"August", 9:"September", 10:"October", 11:"Novemeber",
12:"December"}
InputError = True
while InputError:
try:
BirthDate = str(input("Enter Birth Date in format DDMMYY - "))
except ValueError:
print("Error - Numbers in format DDMMYY only")
InputError = False
DD = BirthDate[0:2]
MM = BirthDate[3:4]
YY = BirthDate[4:6]
if MM == BirthDate[3:4]:
print("Your Birth Month is - ", (CalendarDict[int(MM)]))