0
2

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.

python > 8という数字を008として表示したい > print "{0:0>3}".format(8) または "{value:0>3}".format(value=8) または "%03d" % 8 または format(8, "03d") または str(8).zfill(3) または(Python3.6以降)f"{8:0>3}"

Last updated at Posted at 2015-11-24

参考
http://python.civic-apps.com/string-format-function/

151125d.py
print "{0:0>3}".format(8)
実行
[toLearn]$ python 151125d.py 
008

教えていただいた事項

@shiracamus さんのコメントにて様々な書き方を教えていただきました。

検索で見つかるようにタイトルに追加しました。

0
2
2

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
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?