Skip to content

Instantly share code, notes, and snippets.

@Akiyamka
Created October 8, 2016 11:05
Show Gist options
  • Save Akiyamka/03f589a3351e6fd76cac8e69bb878cc2 to your computer and use it in GitHub Desktop.
Save Akiyamka/03f589a3351e6fd76cac8e69bb878cc2 to your computer and use it in GitHub Desktop.
def find_tags(fileList):
# Принимает файл в виде построчного списка
# Возвращает словарь с координатами тэгов
# Внезапно! может быть использована в виде find_tags(fileList)['тэг']
i = 0
tagDict = {}
for line in fileList:
# Создаем словарь где в качестве ключа -
# название тэга с которого начинается строка
# А в качестве значения - пустой список (нужен для следующего цикла)
tagName = string_recog(line)
tagDict.update({tagName:[]})
for line in fileList:
# Снова пробегаемся по строкам, но этот раз
# в пустой список добавляем номера строк где встречается тэг
tagName = string_recog(line)
array = tagDict[tagName]
array.append(i)
i+=1
# print(tagDict)
return tagDict
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment