相关疑难解决方法(0)

如何用空格填写Python字符串?

我想用空格填写一个字符串.我知道以下适用于零:

>>> print  "'%06d'"%4
'000004'
Run Code Online (Sandbox Code Playgroud)

但是当我想要这个时我该怎么办?

'hi    '
Run Code Online (Sandbox Code Playgroud)

当然我可以测量弦长并做str+" "*leftover,但我想要最短路.

python string string-formatting pad

472
推荐指数
12
解决办法
45万
查看次数

标签 统计

pad ×1

python ×1

string ×1

string-formatting ×1