相关疑难解决方法(0)

Python:格式输出字符串,右对齐

我正在处理包含坐标x,y,z的文本文件

     1      128  1298039
123388        0        2
....
Run Code Online (Sandbox Code Playgroud)

每行使用分为3个项目

words = line.split()
Run Code Online (Sandbox Code Playgroud)

在处理数据之后,我需要在另一个txt文件中写回坐标,以便每列中的项目对齐(以及输入文件).每一行都由坐标组成

line_new = words[0]  + '  ' + words[1]  + '  ' words[2].
Run Code Online (Sandbox Code Playgroud)

std::setw()在C++中是否有类似的操纵器允许设置宽度和对齐?

python alignment string-formatting

133
推荐指数
7
解决办法
22万
查看次数

标签 统计

alignment ×1

python ×1

string-formatting ×1