我有两个清单:
a = ['a', 'b', 'c']
b = [1]
我希望我的输出为:
a, 1
b, 1
c, 1
尝试这样做:
for i, j in zip(a, b):
print i, j
我只得到a, 1
. 我怎样才能使它正确?
这是我的实际情况:
if request.POST.get('share'):
choices = request.POST.getlist('choice')
person = request.POST.getlist('select')
person = ''.join(person)
person1 = User.objects.filter(username=person)
for i, j in izip_longest(choices, person1, fillvalue=person1[-1]):
start_date = datetime.datetime.utcnow().replace(tzinfo=utc)
a = Share(users_id=log_id, files_id=i, shared_user_id=j.id, shared_date=start_date)
a.save()
return HttpResponseRedirect('/uploaded_files/')