新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
創(chuàng)新互聯(lián)Python教程:python的replace函數(shù)怎么用
Python REPLACE() 方法把字符串中的 old(舊字符串) 替換成 new(新字符串),如果指定第三個參數(shù)max,則替換不超過 max 次。

10多年的興賓網(wǎng)站建設(shè)經(jīng)驗,針對設(shè)計、前端、開發(fā)、售后、文案、推廣等六對一服務,響應快,48小時及時工作處理。成都營銷網(wǎng)站建設(shè)的優(yōu)勢是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動調(diào)整興賓建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計,從而大程度地提升瀏覽體驗。成都創(chuàng)新互聯(lián)公司從事“興賓網(wǎng)站設(shè)計”,“興賓網(wǎng)站推廣”以來,每個客戶項目都認真落實執(zhí)行。
replace()方法語法:
str.replace(old, new[, max])
參數(shù)
old -- 將被替換的子字符串。 new -- 新字符串,用于替換old子字符串。 max -- 可選字符串, 替換不超過 max 次
返回值
返回字符串中的 old(舊字符串) 替換成 new(新字符串)后生成的新字符串,如果指定第三個參數(shù)max,則替換不超過 max 次。
以下實例展示了replace()函數(shù)的使用方法:
str = "this is string example....wow!!! this is really string";
print str.replace("is", "was");
print str.replace("is", "was", 3);輸出結(jié)果
thwas was string example....wow!!! thwas was really string thwas was string example....wow!!! thwas is really string
更多學習內(nèi)容,請點擊Python學習網(wǎng)。
網(wǎng)頁標題:創(chuàng)新互聯(lián)Python教程:python的replace函數(shù)怎么用
當前網(wǎng)址:http://m.fisionsoft.com.cn/article/ccsigcd.html


咨詢
建站咨詢
