不是單線...
# Initialise some ASCII art
# For this example, the strings have to have the same number of
# lines.
strings = [
'''
_____
/ /\\
/____/ \\
\\ \/
\\____\/
'''
] * 3
# Split each multiline string by newline
strings_by_column = [s.split('\n') for s in strings]
# Group the split strings by line
# In this example, all strings are the same, so for each line we
# will have three copies of the same string.
strings_by_line = zip(*strings_by_column)
# Work out how much space we will need for the longest line of
# each multiline string
max_length_by_column = [
max([len(s) for s in col_strings])
for col_strings in strings_by_column
]
for parts in strings_by_line:
# Pad strings in each column so they are the same length
padded_strings = [
parts[i].ljust(max_length_by_column[i])
for i in range(len(parts))
]
print(''.join(padded_strings))
輸出:
_____ _____ _____
/ /\/ /\/ /\
/____/ \/____/ \/____/ \
\ \ /\ \ /\ \/
\____\/ \____\/ \____\/
請,張貼'預計result' –