林峰聿 python字串 string內建 built-in方法 methods
vs code 開發環境w3schools截圖
字串程式碼
a="ha,林峰聿kusa,萬歲!很詭異" b= a.replace('萬歲','很棒') print (a) print (b) print ('幾個很?',a.count('很')) print ('很在0,1. .位置', a.find('很')) print ('很在0,1. .位置', a.rfind('很')) print ('a的長度',len(a)) print ('英文大寫',a.upper()) print ('英文小寫',a.lower()) txt = "hello,將第一個字母轉成大寫。" x = txt.capitalize() print (x) print (txt.casefold()) y = txt.center(30) print (txt.center(30)) print (y) print (len(y))
0227.右側太多空白,截圖要更小才清楚。https://keiime.blogspot.com/2024/02/python-string-built-in-methods.html
回覆刪除