這篇文章主要介紹了使用python字符串中str.format函數(shù)的示例,具有一定借鑒價值,需要的朋友可以參考下。希望大家閱讀完這篇文章后大有收獲。下面讓小編帶著大家一起了解一下。
給大家直接演示format函數(shù)的代碼使用:
命名參數(shù)
'{name1}, {name2} and {name3}'.format(name1='gao', name2='fu', name3='shuai') 'gao, fu and shuai'
混合位置參數(shù)、命名參數(shù)
'{name1}, {0} and {name3}'.format("shuai", name1='fu', name3='gao') 'fu, shuai and gao'
科學(xué)數(shù)字記法:
感謝你能夠認真閱讀完這篇文章,希望小編分享使用python字符串中str.format函數(shù)的示例內(nèi)容對大家有幫助,同時也希望大家多多支持創(chuàng)新互聯(lián)網(wǎng)站建設(shè)公司,,關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,遇到問題就找創(chuàng)新互聯(lián)網(wǎng)站建設(shè)公司,,詳細的解決方法等著你來學(xué)習(xí)!