0

这个问题是不言自明的。变量是reply_list。

def db_query():

    chat_data = {}
    queries = A.objects.filter(is_responded = 0)
    for query in queries:
        replies = []
        c_id = query.conversation_id
        b_ids = json.loads(query.sent_to)
        b_ids = b_ids["business_ids"]

        for index in range(len(b_ids)):
            b_ids[index] = int(b_ids[index])

        for b_id in b_ids:

            representative_reply = B.objects.filter(conversation_id = c_id , b_id = b_id)
            user_reply = A.objects.filter(conversation_id = c_id)
            replies.append(chain(representative_reply , user_reply))
            reply_list =[]
            for reply in replies:
                for r in reply:
                    reply_list.append(r.u_query)

            print reply_list               # prints the complete list. But when inside the loop , prints only the last appended value..........SEE DOWN........
            business_data = C.objects.filter(b_id = b_id)

            for data in business_data:
                print reply_list              # prints only the last appended value .... Why? 

我想要的是完整的reply_list 应该打印在business_data循环内。

请有任何建议。我要去哪里错了。

4

0 回答 0