7
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

数値の桁数に応じて頭に0埋めする簡単な方法 [Python]

Posted at

ちょうべんり。

In [1]: '{0:03d}'.format(2)
Out[1]: '002'

In [2]: '{0:03d}'.format(2000)
Out[2]: 2000

空白地も埋められる。

In [3]: '{0:3d}'.format(2)
Out[3]: '  2'
7
9
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?