这是我得到的文本文件:
我尝试的是将txt文件中的所有点变成最接近的字母,并以字符串格式打印出来。
为了实现这个目标,我得到的是txt文件中每个项目的最近点: 我尝试做的是首先将列表中每个元素的小写打印为行*列字符串网格格式,就像上面的例子一样,然后将原始字母的索引更改为大写。
但是我从第一步就无法将其以字符串网格格式打印出来。如何做到这一点?
......B..
.........
...A.....
.........
.......D.
.........
.C.......
.....E...
.........
从这段文本中,我为了获取文本文件中每个点最接近的字母,制作了以下元素。
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文件中的所有点变成最接近的字母,并以字符串格式打印出来。
aaaabbBbb
aaaaabbbb
aaaAaabdd
aaaaaaddd
ccaaaddDd
cccceeddd
cCcceeedd
ccceeEeee
ccceeeeee
为了实现这个目标,我得到的是txt文件中每个项目的最近点: 我尝试做的是首先将列表中每个元素的小写打印为行*列字符串网格格式,就像上面的例子一样,然后将原始字母的索引更改为大写。
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'}]
但是我从第一步就无法将其以字符串网格格式打印出来。如何做到这一点?