手工小改一下,为半角字符添加一个空格对齐排版,去掉末尾句号不知道copilot怎么想的,删除那行代码了。
import sys
def create_matrix(text):
# 按照竖排版规则,将文本填入 8x8 的矩阵
matrix = [[" "] * 8 for _ in range(8)]
row, col = 0, 7 # 从右到左对齐
for char in text:
matrix[row][col] = char
row = (row + 1) % 8
if row == 0:
col = (col - 1) % 8
# 输出竖排版的文本
for row in matrix:
lc = [c if ord(c) > 255 else ' ' + c for c in row]
print('│' + '│'.join(lc) + '│')
print('')
if len(sys.argv) < 2:
print("竖排版显示用法:python script.py \"输入的中文字符串\"")
else:
input_text = sys.argv[1]
input_text = input_text.replace('\n', '')
while input_text:
create_matrix(input_text[:64]) # 每次处理 64 个字符
input_text = input_text[64:] # 剩余部分
【 在 poocp 的大作中提到: 】
: 让Copilot写的:
: ...................
--
FROM 171.221.52.*