Python 基礎學習16 17

字符串的格式化 按照統一的規格輸出(轉換爲指定格式) format函數python >>> "{0}eaea{1}".format('a','c') 'aeaeac %「位置參數」format(關鍵字參數) "{a}".foamat(a='c') %另外一種方法 >>> "{0:.1f}".format(27.32421421) '27.3' %0表明位置參數 .1指寬度不定義,小數點後留一位
相關文章
相關標籤/搜索