我正在尝试使这个板居中,这是代码,我尝试使用 %*s,但没有成功。任何想法?
board = [["1","2","2"],["8*1","2@3","5*6"],["9","5","8"],["2","2","2"],
["5*6","6*8","0@2"],["1","2","8"],["1","9","8"],["2*7","7*5","4@2"],["1","3","3"]]
counter = 0
print("--------------+---------------+-------------------")
for row in board:
counter += 1
print("|" "%s" "|") % (" | ".join(row).center(47))
if counter == 3 or counter == 6 or counter == 9:
print("---------------+---------------------+--------------")
每个盒子的输出应该是这样的
+-----------+
| 1 | 1 | 9 |
|2@3|1*6|7*2|
| 4 | 1 | 2 |
+-----------+