当前位置:   article > 正文

python 按列对齐,Python修改文本列对齐

python获取文本l列对齐

letter                   ->

LadderScore0                   ->

LadderScore1                   ->

LadderScore2                   ->

LadderScore3                   ->

LadderScore4                   ->

LadderScore5                   ->

LadderScore6                   ->

LadderScore7                   ->

LadderScore8                   ->

LadderScore9                   ->

WeeklyDoneCount0                   ->

WeeklyDoneCount1                   ->

WeeklyDoneCount2                   ->

WeeklyDoneCount3                   ->

WeeklyDoneCount4                   ->

WeeklyDoneCount5                   ->

WeeklyDoneCount6                   ->

WeeklyDoneCount7                   ->

WeeklyDoneCount8                   ->

WeeklyDoneCount9                   ->

LastFPS0                   ->

LastFPS1                   ->

LastFPS2                   ->

LastFPS3                   ->

LastFPS4                   ->

LastFPS5                   ->

LastFPS6                   ->

LastFPS7                   ->

LastFPS8                   ->

LastFPS9                   ->

脚本内容如下#!/usr/bin/env python

#coding:utf-8

import os

format = '%-*s%-*s\n'

file = open('a.txt','r')

f = open('file.txt','a')

all = ""

for i in file:

i=i.split(' ')

a = format % (20, i[0], 20, '->')

all += a

f.write(a)

f.close()

file.close()

print all

文件展示

68c6171a2dd019b8dd5d9b7e92d9547e.png

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/294519
推荐阅读
相关标签
  

闽ICP备14008679号