這是我得到的txt文件:......B..............A.....................D...........C............E............從這個(gè)文本中,我制作了以下元素,用于從 txtfile 中的每個(gè)點(diǎn)獲取壁櫥字母表。location_alpha ={(2, 3): 'A', (0, 6): 'B', (6, 1): 'C', (4, 7): 'D', (7, 5): 'E'}location_allpoint = [(0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (4, 8), (5, 0), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (5, 7), (5, 8), (6, 0), (6, 1), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6), (6, 7), (6, 8), (7, 0), (7, 1), (7, 2), (7, 3), (7, 4), (7, 5), (7, 6), (7, 7), (7, 8), (8, 0), (8, 1), (8, 2), (8, 3), (8, 4), (8, 5), (8, 6), (8, 7), (8, 8)]我嘗試做的是將txt文件中的所有點(diǎn)更改為最接近的字母并以字符串格式打?。?nbsp; aaaabbBbb aaaaabbbb aaaAaabdd aaaaaaddd ccaaaddDd cccceeddd cCcceeedd ccceeEeee ccceeeeee為此,我得到的是 txt.file 中每個(gè)項(xiàng)目的最近點(diǎn):我試圖做的是首先將列表中每個(gè)元素的小寫(xiě)打印為 row*col 字符串網(wǎng)格格式,例如上面的示例,然后更改原始字母表的索引為大寫(xiě)。 for i in nearest_alphabet_from_point: if len(i) ==2: # one that comes first lexicographically must be used in case ex){'A', 'C'} ==> 'A'nearest_alphabet_from_point =[{'A'}, {'A'}, {'A'}, {'A'}, {'B'}, {'B'}, {'B'}, {'B'}, {'B'}, {'A'}, {'A'}, {'A'}, {'A'}, {'A'}, {'B'}, {'B'}, {'B'}, {'B'}, {'A'}, {'A'}, {'A'}, {'A'}, {'A'}, {'A'}, {'B'}, {'D'}, {'D'}, {'A', 'C'}, {'A'}, {'A'}, {'A'}, {'A'}, {'D', 'A'}, {'D'}, {'D'}, {'D'}, {'C'}, {'C'}, {'A', 'C'}, {'A'}, {'A'}, {'D'}, {'D'}, {'D'}, {'D'}, {'C'}, {'C'}, {'C'}, {'C'}, {'E'}, {'E'}, {'D'}, {'D'}, {'D'}, {'C'}, {'C'}, {'C'}, {'C'}, {'E'}, {'E'}, {'E'}, {'D'}, {'D'}, {'C'}, {'C'}, {'C'}, {'E'}, {'E'}, {'E'}, {'E'}, {'E'}, {'E'}, {'C'}, {'C'}, {'C'}, {'E'}, {'E'}, {'E'}, {'E'}, {'E'}, {'E'}]但我從第一步開(kāi)始就無(wú)法以字符串網(wǎng)格格式打印它。我怎樣才能做到這一點(diǎn)?
查看完整描述