發表文章

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

吳弘彬Python字串string

圖片
vs code與w3schools截圖 程式碼 def my_function():   print("你好 HI IS ME") my_function() txt = "吳弘彬 愛 你好, 你好是我 are my favorite 我是你好" print(txt.count("你好")) print('先練習內建函數len',len(txt)) print('find',txt.find("是我")) print('rfind',txt.rfind("你好")) w3schools字串方法列表 a 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 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 position of where it w...