- 完成一段程式撰寫後,常有需求將生成的變數輸出檢視
- 格式化輸出(print with format)
- Python 中以大括號 {} 搭配 .format() 方法做格式化輸出
asset_tony_stark = 12400000000
print("The net worth of Stark Industries is ${} USD.".format(asset_tony_stark))
## The net worth of Stark Industries is $12400000000 USD.
print("The net worth of Stark Industries is ${:,} USD.".format(asset_tony_stark))
## The net worth of Stark Industries is $12,400,000,000 USD.
print("The net worth of Stark Industries is ${:,.2f} USD.".format(asset_tony_stark))
## The net worth of Stark Industries is $12,400,000,000.00 USD.
Reference: