發表文章

目前顯示的是 2月, 2024的文章

蔡佩珊Python字串string多法methods

圖片
單元影片371 vs code與w3schools截圖 程式碼 lower小寫 case字體 upper大寫 swaps交換 txt = "蔡佩珊 love 小蜜柑, 小蜜柑是我 are my favorite 水果小蜜柑" print(txt.count("小蜜柑")) print('先練習內建函數len',len(txt)) print('find',txt.find("小蜜柑")) print('rfind',txt.rfind("小蜜柑")) print("print列印,字串string字元character的組合") print(txt.title()) print(txt.lower()) print(txt.upper()) print(txt.swapcase()) print(txt.zfill(32)) print(txt.startswith("任")) print(len(txt)) for i in range(33333, 33344): print(chr(i)) for i in range(65, 70): print(chr(i)) w3schools字串方法列表 Method Description capitalize() Converts the first character to upper case casefold() Converts string into lower case center() Returns a centered string count() Returns the number of times a specified value occurs in a string encode() Returns an encoded version of the string endswith() Returns true if the string ends with the specified value expandtabs() Sets the tab size of the string ...