劉任昌Python字串string方法methods

單元371影片

vs code與w3schools截圖

程式碼

txt = "劉任昌Love蘋果,蘋果我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字串方法列表

MethodDescription
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 was found
isalnum()Returns True if all characters in the string are alphanumeric
isalpha()Returns True if all characters in the string are in the alphabet
isascii()Returns True if all characters in the string are ascii characters
isdecimal()Returns True if all characters in the string are decimals
isdigit()Returns True if all characters in the string are digits
isidentifier()Returns True if the string is an identifier
islower()Returns True if all characters in the string are lower case
isnumeric()Returns True if all characters in the string are numeric
isprintable()Returns True if all characters in the string are printable
isspace()Returns True if all characters in the string are whitespaces
istitle()Returns True if the string follows the rules of a title
isupper()Returns True if all characters in the string are upper case
join()Converts the elements of an iterable into a string
ljust()Returns a left justified version of the string
lower()Converts a string into lower case
lstrip()Returns a left trim version of the string
maketrans()Returns a translation table to be used in translations
partition()Returns a tuple where the string is parted into three parts
replace()Returns a string where a specified value is replaced with a specified value
rfind()Searches the string for a specified value and returns the last position of where it was found
rindex()Searches the string for a specified value and returns the last position of where it was found
rjust()Returns a right justified version of the string
rpartition()Returns a tuple where the string is parted into three parts
rsplit()Splits the string at the specified separator, and returns a list
rstrip()Returns a right trim version of the string
split()Splits the string at the specified separator, and returns a list
splitlines()Splits the string at line breaks and returns a list
startswith()Returns true if the string starts with the specified value
strip()Returns a trimmed version of the string
swapcase()Swaps cases, lower case becomes upper case and vice versa
title()Converts the first character of each word to upper case
translate()Returns a translated string
upper()Converts a string into upper case
zfill()Fills the string with a specified number of 0 values at the beginning
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 was found
isalnum()	Returns True if all characters in the string are alphanumeric
isalpha()	Returns True if all characters in the string are in the alphabet
isascii()	Returns True if all characters in the string are ascii characters
isdecimal()	Returns True if all characters in the string are decimals
isdigit()	Returns True if all characters in the string are digits
isidentifier()	Returns True if the string is an identifier
islower()	Returns True if all characters in the string are lower case
isnumeric()	Returns True if all characters in the string are numeric
isprintable()	Returns True if all characters in the string are printable
isspace()	Returns True if all characters in the string are whitespaces
istitle()	Returns True if the string follows the rules of a title
isupper()	Returns True if all characters in the string are upper case
join()	Converts the elements of an iterable into a string
ljust()	Returns a left justified version of the string
lower()	Converts a string into lower case
lstrip()	Returns a left trim version of the string
maketrans()	Returns a translation table to be used in translations
partition()	Returns a tuple where the string is parted into three parts
replace()	Returns a string where a specified value is replaced with a specified value
rfind()	Searches the string for a specified value and returns the last position of where it was found
rindex()	Searches the string for a specified value and returns the last position of where it was found
rjust()	Returns a right justified version of the string
rpartition()	Returns a tuple where the string is parted into three parts
rsplit()	Splits the string at the specified separator, and returns a list
rstrip()	Returns a right trim version of the string
split()	Splits the string at the specified separator, and returns a list
splitlines()	Splits the string at line breaks and returns a list
startswith()	Returns true if the string starts with the specified value
strip()	Returns a trimmed version of the string
swapcase()	Swaps cases, lower case becomes upper case and vice versa
title()	Converts the first character of each word to upper case
translate()	Returns a translated string
upper()	Converts a string into upper case
zfill()	Fills the string with a specified number of 0 values at the beginning

留言

  1. https://wang-yu-jia-wangyujia.blogspot.com/2024/02/pythonstringmethods.html

    回覆刪除
    回覆
    1. 沒有使用vscode? 截圖一定要原始大小!

      刪除
  2. https://russellma2005525.blogspot.com/2024/02/pythonstringmethods.html

    回覆刪除
  3. https://hank20050328.blogspot.com/2024/02/pythonstringmethods.html

    回覆刪除
    回覆
    1. 動手做,很傑出!截圖小一點,才能看清楚。

      刪除
  4. https://laiweikaiaaa.blogspot.com/2024/02/pythonstringmethods.html

    回覆刪除
    回覆
    1. 截圖要清楚一點!自己做,很優秀!

      刪除
  5. https://www.blogger.com/blog/post/edit/preview/4616311045112546689/7845862625363149320

    回覆刪除
    回覆
    1. h1要有大於、小於標記,一定要自己使用

      刪除
  6. https://wuhongbing.blogspot.com/2024/02/pythonstring.html

    回覆刪除
    回覆
    1. 自己做,就是優!要繼續改善截圖。

      刪除
  7. https://naiyuanzhang1226.blogspot.com/2024/02/pythonstringmethods.html

    回覆刪除
    回覆
    1. 截圖清晰,迴圈,補充,神優秀。

      刪除
  8. https://chan-wan-yi.blogspot.com/2024/02/pythonstringmethods.html

    回覆刪除
  9. https://kuoyiting.blogspot.com/2024/02/python-string-methods.html

    回覆刪除
  10. https://shenzhenxuan.blogspot.com/2024/02/pythonstringmethods.html

    回覆刪除
  11. https://su-you-an.blogspot.com/2024/02/pythonstringmethods.html

    回覆刪除
  12. https://jhuang-huei.blogspot.com/2024/02/pythomstringmethods.html

    回覆刪除
  13. https://linziwei0308.blogspot.com/2024/02/pythonstringmetods.html

    回覆刪除
  14. https://www.blogger.com/blog/post/edit/preview/5779881926535543652/6577989269403138257

    回覆刪除
  15. https://yiingxxn.blogspot.com/2024/02/pythonstringmethods.html

    回覆刪除
    回覆
    1. 截圖清晰!迴圈。盡量多寫,多從網路整理相關資訊,多累積知識,創造智慧。

      刪除
  16. https://0209tongting.blogspot.com/2024/02/pythonstringmethods.html

    回覆刪除
  17. https://www.blogger.com/blog/post/edit/preview/4393298692252949908/1666155943399848762

    回覆刪除
  18. https://shirong046.blogspot.com/2024/02/pythonstring.html

    回覆刪除
  19. https://stanley-ouo.blogspot.com/2024/02/pythonstringmethods.html

    回覆刪除
  20. https://sandy06252023.blogspot.com/2024/02/pythonstringmethods.html

    回覆刪除
  21. https://zhen-zhen4869.blogspot.com/2024/02/pythonstringmethods.html

    回覆刪除
  22. https://wujiaqi1010.blogspot.com/2024/02/pythonstringmethods.html

    回覆刪除
  23. https://caipeishan1223.blogspot.com/2024/02/pythonstringmethods.html

    回覆刪除
  24. https://www.blogger.com/blog/post/edit/1248398302505076375/8238055741975894445

    回覆刪除
  25. https://wnagenqiiiiiiiiiiii.blogspot.com/2024/03/pythonstringmethods.html

    回覆刪除
  26. https://linchinppei.blogspot.com/2024/03/pythonstringmethods.html

    回覆刪除
    回覆
    1. 妳家裡電腦有裝vs code?請告訴我真相,不要嚇唬我!

      刪除
  27. https://zzl1102.blogspot.com/2024/03/pythonstringmethods.html

    回覆刪除
  28. https://giinasmile.blogspot.com/2024/03/pythonstringmethods.html

    回覆刪除
  29. https://yang0218.blogspot.com/2024/03/pythonstringmethods-2-29-2024-python.html

    回覆刪除
  30. https://wenhuichenchen.blogspot.com/2024/03/pythonstringmethods.html

    回覆刪除
  31. https://xu0625.blogspot.com/2024/03/pythonstringmethods.html

    回覆刪除
  32. https://lukelu0928.blogspot.com/2024/03/pythonwriteaw.html

    回覆刪除

張貼留言

這個網誌中的熱門文章

劉任昌python串列List(陣列Array),元組Tuple,集合Set,字典Dict

2025年3月4日上課Python 陣列array串列的函數(方法)

劉任昌Javascript物件導向Python物件導向