算法

import re

test = ['1', '2', '3', '4##', '4-----', '5', '6##', '6-------', 'table1', 'table2','123','456','789##','34']


def mergerPage(test):
    test1 = []
    index_num = []
    for i in range(len(test)):
        index = []
        if test[i].endswith('##'):
            index.append(i+1)
            index_num.append(i+1)
            top_line = test[i + 1]
            test[i] += top_line
            test1.append(test[i])
        if not index:
            test1.append(test[i])
    data = [test1[i] for i in range(len(test1)) if (i not in index_num)]
    return data

if __name__ == '__main__':
    test = ['1', '2', '3', '4##', '4-----', '5', '6##', '6-------', 'table1', 'table2', '123', '456', '789##', '34']
    data = mergerPage(test)
    print(data)

你可能感兴趣的:(算法)