Python format() 組み込み関数
format_spec によって制御される、「フォーマットされた」表現に値を変換します。format_spec の解釈は、value 引数の型に依存します。[...].
Introduction
Python の format() 関数は、書式設定された文字列を作成できる多用途な組み込み関数です。値を変数に埋め込み、その配置を制御し、小数点以下の桁数やパディングなどの表示を指定する方法を提供します。
Examples
name = 'Micheal'
company = 'Dunder Mifflin'
print("My name is {0} and I work for {1}.".format(name, company))
# Formatting string (faster and easier)
print(f"My name is {name} and I work for {company}.")
My name is Micheal and I work for Dunder Mifflin.
My name is Micheal and I work for Dunder Mifflin.