class wenket(View):
print "qqqqqqqqqqqqqq"
def get(self,request):
number1=request.GET['number']
print"bbbbbbbbbb",number1
return self.primenumbdef(number1)
def primenumbdef(self,number1):
print"aaaaaaaaaaaaaaaaaaaaaaaa"
if number1==100:
return HttpResponse(d({"value of number is 100":number1}))
else:
return HttpResponse(d({"value of number is not 100": number1}))
答案 0 :(得分:1)
您从request.GET['number']
对象获取的request
是一个字符串('100'
)。您应该考虑将其投放到int
,然后将其与100
进行比较。也就是说,
def get(self,request):
number1 = int(request.GET['number'])
print"bbbbbbbbbb", number1
return self.primenumbdef(number1)
或者如果你想抓住number
可能不是数字的边缘情况,试试这个:
def get(self,request):
number1 = request.GET['number']
try:
number1 = int(number1)
except ValueError as e:
# handle case here
else:
print"bbbbbbbbbb",number1
return self.primenumbdef(number1)