如何在python中将不同的字符串附加到特定长度。示例:
enter Chunks_of_rows = []
for line in text_blocks: # text_blocks is a json file
lines = line['lines']
for chunk in lines:
bbox = chunk['bbox']
for k,v in row_chunk.items():# k is the bbox and v is the number of times k appears.
# So I want to append the k to a list and split the list to another list.
# ie. if k appears ten times it should appends move to a new line after it appends the last object
# print(k,v)
if k == bbox[1]:
span = chunk['spans']
# print(span)
for text in span:
text = text['text']
Chunks_of_rows.append(text)
#Here is the bbox
82.32080078125
811.7716064453125
73.30280303955078
135.97779846191406
167.1802978515625
181.353515625
209.70013427734375
756.1480102539062
756.2940063476562
765.7479858398438
765.8939819335938
775.3480224609375
775.4940185546875
259.69671630859375
259.69671630859375
259.69671630859375
259.69671630859375
270.88531494140625
270.88531494140625
270.88531494140625
270.88531494140625
270.88531494140625
270.88531494140625
270.88531494140625
270.88531494140625
270.88531494140625
282.07379150390625
282.07379150390625
282.07379150390625
282.07379150390625
282.07379150390625
282.1163024902344
282.07379150390625
282.07379150390625
282.07379150390625
282.07379150390625
297.54833984375
315.3733215332031
315.3733215332031
315.3733215332031
315.3733215332031
315.3733215332031
315.3733215332031
315.3733215332031
315.3733215332031 315.3733215332031 315.3733215332031 331.2724304199219 331.2724304199219 331.2724304199219 331.2724304199219 331.2724304199219 331.2724304199219 331.2724304199219 331.2724304199219 331.2724304199219 331.2724304199219 346.9676208496094 346.9676208496094 346.9676208496094 346.9676208496094 346.9676208496094 346.9676208496094 361.18621826171875 378.8072204589844 378.8072204589844 394.9104309082031 394.9104309082031 394.9104309082031 394.9104309082031 394.9104309082031 394.9104309082031 394.9104309082031 394.9104309082031 394.9104309082031 394.9104309082031 410.8095397949219 410.8095397949219 410.8095397949219 410.8095397949219 410.8095397949219 410.8095397949219 410.8095397949219 410.8095397949219 410.8095397949219 410.8095397949219 426.708740234375 426.708740234375 426.708740234375 426.708740234375 426.708740234375 426.708740234375 426.708740234375 426.708740234375 426.708740234375 426.708740234375 442.6078186035156 442.6078186035156 442.6078186035156 442.6078186035156 442.6078186035156 442.6078186035156 442.6078186035156 442.6078186035156 442.6078186035156 442.6078186035156 458.3030090332031 458.3030090332031 474.4063415527344 474.4063415527344 474.4063415527344 474.4063415527344 474.4063415527344 474.4063415527344 474.4063415527344 474.4063415527344 474.4063415527344 474.4063415527344 490.3053283691406 490.3053283691406 490.3053283691406 490.3053283691406 490.3053283691406 490.3053283691406 490.3053283691406 490.3053283691406 490.3053283691406 490.3053283691406 506.2044372558594 506.2044372558594 506.2044372558594 506.2044372558594 506.2044372558594 506.2044372558594 506.2044372558594 506.2044372558594 506.2044372558594 506.2044372558594 521.899658203125 521.899658203125 521.899658203125 521.899658203125 521.899658203125 521.899658203125 521.899658203125
行或列表应根据bbox出现并拆分或追加到该长度的频率来确定。请提出任何想法?。