字符图网格
假定有一个列表的列表,内层列表的每个值都是包含一个字符的字符串,像这样:
grid = [[‘.’, ‘.’, ‘.’, ‘.’, ‘.’, ‘.’],
[‘.’, ‘O’, ‘O’, ‘.’, ‘.’, ‘.’],
[‘O’, ‘O’, ‘O’, ‘O’, ‘.’, ‘.’],
[‘O’, ‘O’, ‘O’, ‘O’, ‘O’, ‘.’],
[‘.’, ‘O’, ‘O’, ‘O’, ‘O’, ‘O’],
[‘O’, ‘O’, ‘O’, ‘O’, ‘O’, ‘.’],
[‘O’, ‘O’, ‘O’, ‘O’, ‘.’, ‘.’],
[‘.’, ‘O’, ‘O’, ‘.’, ‘.’, ‘.’],
[‘.’, ‘.’, ‘.’, ‘.’, ‘.’, ‘.’]]
你可以认为 grid[x][y]是一幅“图”在 x、y 坐标处的字符,该图由文本字符组
成。原点(0, 0)在左上角,向右 x 坐标增加,向下 y 坐标增加。
复制前面的网格值,编写代码用它打印出图像。
…OO.OO…
.OOOOOOO.
.OOOOOOO.
…OOOOO…
…OOO…
…O…
代码
```python
for j in range(len(grid[1])):
for i in range(len(grid)):
print(grid[i][j],end='')
print('\n')