Python home_ajax()只需1个参数(给定0)

时间:2015-03-28 05:56:42

标签: python django function

def all_ajax(request, *x):

    if request.is_ajax(): 
        Path = request.GET.get('Path')
        print Path
        return HttpResponse('ajax called with myvar: %s' % Path)

    for var in x:
        lists = var
        for w in lists:
            print w

def home_ajax(request):

    if request.is_ajax():

        climg = request.GET.get('climg')
        simg =  'C:\Users\ikesavan\Desktop\searchengine' + climg
        path = 'C:\Users\ikesavan\Desktop\images'
        pathindex='C:\Users\ikesavan\Desktop\searchengine\index.cpickle'
        qimg= str(simg)

        i=1
        queryImage = cv2.imread(qimg)
        desc = RGBHistogram([8, 8, 8])
        queryFeatures = desc.describe(queryImage)


        index = cPickle.loads(open(pathindex).read())
        searcher = Searcher(index)
        results = searcher.search(queryFeatures)
        print "query: %s" % (qimg)
        for j in xrange(0, 100):
                (score, imageName) = results[j]
                if score  < 0.6:
                    path = qimg + "/%s" % (imageName)
                    lists = all_ajax(imageName)
                else:
                    break           

    cv2.waitKey(0)

    return HttpResponse('ajax called with myvar: %s' % climg)

home_ajax()

这里我想将imageName值传递给call_ajax函数中的函数all_ajax,而在call_ajax函数中它已经有了参数。

1 个答案:

答案 0 :(得分:2)

删除您不需要任何参数调用home_ajax函数的代码的最后一行:

home_ajax()