Created
October 8, 2016 11:05
-
-
Save Akiyamka/bda480b60e09d443ac0ec517b23c3b06 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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