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.7。
input()
。因为它会对任意用户输入调用eval()
,这是一个非常严重的安全漏洞。请参阅SO成员Ned Batchelder的文章Eval really is dangerous。 - PM 2Ring