私はテーブル内のすべてのフィールドを整列する方法を知っている:テーブルの2番目と4番目の列だけを揃える方法は?
r=["this is my text of line1",
"and this was one more line",
"another line of text to display"]
import re
splitter = "\s+"
columnstotal = []
for i in range(0,len(r)):
#remove splitter
columns = re.split(splitter, r[I])
#keep splitter
columns = re.split('(' + splitter + ')', r[i])
columnstotal.append(columns)
と再び.format()を使用して列を表示する
が、どのように私は唯一の2列を揃える行います
列2を(右位置合わせ)+列4(左揃え)?
期待出力:
this is| my |text of line1
and this| was |one more line
another line| of |text to display
を複数の入力データを与え、そしてあなたが出力として見たい正確な結果をしてください。 – jsbueno
また、 'r 'の部分が必要な場合、Pythonの' r'の長さに 'for'という数字をつけないように気をつけてください:単に' rの部分のために '' – jsbueno
@ jsbueno、私の質問を更新しました – Reman