print "What is your name?",
name = len(raw_input())
print name
print "How old are you?",
age = int(input())
print "What month were you born in? ",
month = int(input())
if (month>12) or (0>month):
print "That does not exist"
else:
all = (name+age+month)
print "Your name length plus your age plus",
print "the month you were born is equal to:",
print all
如果您運行的代碼有效,但在提示輸入月份編號時,如果輸入8,它將起作用,但如果輸入08,則不會。有人可以告訴我爲什麼。我使用Python 2.7Python:爲什麼不接受01或02或03的月份輸入?
請不要在Python 2中使用'input()',因爲它在任意用戶輸入上調用'eval()',這是一個_huge_安全缺陷。請參閱SO成員Ned Batchelder的[Eval really dangerous](http://edbatchelder.com/blog/201206/eval_really_is_dangerous.html)。 – 2015-02-24 03:32:20