You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
def format_output(value_list):
len_value_list, value_len_lists, max_space = [], [], []
max_space = []
value_list_vertical = list(zip(*value_list[::-1]))
for i in value_list_vertical:
value_len_list = []
for j in i:
num = 0
for k in j:
if '\u4e00' <= k <= '\u9fff':
num += 2
else:
num += 1
value_len_list.append(num)
value_len_lists.append(value_len_list)
max_space.append(max(value_len_list))
value_list_len = []
for i in list(zip(*value_len_lists[::-1])):
value_list_len.append(list(reversed(i)))
value_list_len = list(reversed(value_list_len))
for i_index, i_value in enumerate(value_list):
result = ' '
for j_index, j_value in enumerate(i_value):
result += j_value + '\x20' * (max_space[j_index] - int(value_list_len[i_index][j_index]) + 10)
print(result)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
我使用python写了一个小东西,可以把输入的二维列表格式化输出,可能代码本身还有点小bug,但是仍然不影响这个来自于windterm2.6.0 windows版本的bug的复现
当输入的二维列表中存在中英文混用的时候,在windterm2.6.0 windows版本中,会存在无法对其的情况,但其他terminal暂时没有发现此种情况
(个人代码能力有待提升,变量取名也有点梦幻,多见谅!!)
Beta Was this translation helpful? Give feedback.
All reactions