發表文章

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

王鈺嘉Python字串string方法methods

圖片
單元371影片 vs code與w3schools截圖 程式碼 txt = "王鈺嘉 love 橘子, 橘子是我 are my favorite 水果橘子" print(txt.count("橘子")) print('先練習內建函數len',len(txt)) print('find',txt.find("橘子")) print(''rfind',txt.rfind("橘子")) 函數 LEN(字串) CHR(字碼) Lenght charactor 字元 字串=字元組元 swaps 金融工具 upper()大寫 lower()小寫 swapcase()大←→小 w3schools字串方法列表 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 find() Searches the string for a specified value and returns the position of where it was found format() Formats specified values in a string format_map() Formats specified values in a string index() Searches the string for a specified value and returns the...