Мой алгоритм сравнивает загруженный документ с другими документами и записывает в выходной отчет, например, «x часть загруженного документа найдена в y документе» и так далее. Теперь я хочу передать эти отчеты моему шаблону HTML, но не знаю, как можно присвоить значение для l oop какой-либо переменной. Вот часть моего кода:
views.py
:
for each_file in files:
other_docs = open(each_file, 'r')
other_docs_words = other_docs.read().lower().split()
for i in range(len(other_docs_words) - 4):
for j in range(len(other_docs_words)+1):
if(j-i == 5):
each_five_others = other_docs_words[i:j]
for original_each_five in iterate():
if(original_each_five == each_five_others):
found_count += 1
# This is the part that I want to output on HTML page.
report.write('{} part of document found in {} document. \n'.format(
original_each_five, each_file))
else:
pass
else:
pass