【问题标题】:convert multiple columns vertical text to horizontal [closed]将多列垂直文本转换为水平[关闭]
【发布时间】:2021-08-19 10:12:29
【问题描述】:

我试过这些,但它只适用于一列。 使用notepad++python。任何可以处理多列文本的解决方案?

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

# Output:
today 
is 
monday

【问题讨论】:

标签: python notepad++ text-processing


【解决方案1】:

你可以很容易地用一个循环来做到这一点,比如:

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)

【讨论】:

    猜你喜欢
    • 2018-12-31
    • 2014-10-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-16
    相关资源
    最近更新 更多