Python 将多列垂直文本转换为水平文本

Python 将多列垂直文本转换为水平文本,python,notepad++,python-textprocessing,Python,Notepad++,Python Textprocessing,我试过这些,但只针对一个专栏。 使用和。有什么解决方案可以处理多列文本 # Input: tim oso d n a d y a y # Output: today is monday 使用循环可以相当轻松地完成此操作,例如: s = "tim\noso\nd n\na d\ny a\n y" bits = s.split('\n') lines = ['' for i in range(0, len(bits[0]))] for bit in bits:

我试过这些,但只针对一个专栏。 使用和。有什么解决方案可以处理多列文本

# Input:
tim
oso
d n
a d
y a
  y

# Output:
today 
is 
monday

使用循环可以相当轻松地完成此操作,例如:

s = "tim\noso\nd n\na d\ny a\n  y"
bits = s.split('\n')
lines = ['' for i in range(0, len(bits[0]))]
for bit in bits:
  for i in range(0, len(bit)):
    if bit[i] != ' ':
      lines[i] += bit[i]
'\n'.join(lines)

谢谢你,伙计。正是我所需要的。请拿着,阅读,和,并提供一个。“为我实现此功能”是本网站的主题。你必须做出诚实的尝试,然后问一个关于你的算法或技术的具体问题。