Python format 格式化函數

Python 字符串 Python 字符串 Python2.6 開始,新增了一種格式化字符串的函數 str.format(),它增強了字符串格式化的功能。 基本語法是通過 {} 和 : 來代替以前的 % 。 format 函數可以接受不限個參數,位置可以不按順序。 實例 「{} {}」.format(「hello」, 「world」) # 不設置指定位置,按默認順序 ‘hello world’ 「
相關文章
相關標籤/搜索