我有两个脚本,一个完成工作,另一个脚本有一个为变量提供正确值的函数。无论如何,当使用脚本(1)
中的参数调用脚本(2)中的函数时,我收到以下错误脚本1(问题最后一行COUNT_help.months():
while True:
day = raw_input("Please Enter The Day: ")
month = raw_input("Please Enter The Month: ")
year = raw_input("Please Enter The Year: ")
if day.isdigit():
if day > 0:
correctcheck = "1"
else:
print "You Did Not Enter A Valid Day"
errormsg = "1"
break
else:
print "You Did Not Enter A Valid Day"
errormsg = "1"
break
if month.isdigit():
if month > 0:
correctcheck = "2"
else:
print "You Did Not Enter A Valid Month"
errormsg = "1"
break
else:
print "You Did Not Enter A Valid Month"
errormsg = "1"
break
if year.isdigit():
if year > 0:
correctcheck = "3"
else:
print "You Did Not Enter A Valid Year"
errormsg = "1"
break
else:
print "You Did Not Enter A Valid Year"
errormsg = "1"
break
if correctcheck == "3":
COUNT_help.months(months = month)
print month
print months
脚本2:
jan = 1
feb = 32
mar = 60
apr = 91
may = 121
jun = 152
jul = 182
aug = 213
sep = 244
obr = 274
nov = 305
dec = 335
def months(months = ""):
if months == "1":
months = jan
return months
if months == "2":
months = feb
return months
if months == "3":
months = mar
return months
if months == "4":
months = apr
return months
if months == "5":
months = may
return months
if months == "6":
months = jun
return months
if months == "7":
months = jul
return months
if months == "8":
months = aug
return months
if months == "9":
months = sep
return months
if months == "10":
months = obr
return months
if months == "11":
months = nov
return months
if months == "12":
months = dec
return months
答案 0 :(得分:1)
您需要在某处分配COUNT_help.months(months = month)
的结果。另请查看datetime
库。
if correctcheck == "3":
months = COUNT_help.months(months = month)
print month
print months