Я пытаюсь найти текстовый блок и поместить некоторые строки в массив словарей. Итак, словарь для каждого текстового блока, который я нахожу. например следующий текст:
Код: Выделить всё
some
other
text
address-object object1
name "name1"
uuid 4ac9cf52-02b5-eecf-0100-18c24100da5e
zone zone1
host ip1
exit
address-object object2
name "name2"
uuid a5c02150-a47e-748d-0100-18c24100da5e
zone zone2
host ip2
exit
some
more text
Код: Выделить всё
[[host:ip1,zone:zone1],[host:ip2,zone:zone2]]I have tried to loop through the text file but cannot get the looping through the block correct. I think I have to use some form of iteration but I am not sure. I end up with a single array with all the items from the first address-object line until the some keyword. I need a loop for each address-object and got the next when I encounter an empty line.
Источник: https://stackoverflow.com/questions/781 ... nary-array