w3schools字串str, format, len, slicing[::]

w3schools

Python程式碼

b = "劉德華大烏龜" #python字串單或雙引號都可
#    0 1 2 3 4 5 6
#       -6-5-4-3-2-1
print("字串長度:"+str(len(b))) #相同字串型態才能串接
print("反過來:"+b[::-1])
print(b[:3]) #b字串的0,1,2
print(b[-4:-1])
print(b[-8:-4])
x = '火鍋'
y = 9999
myorder = "我希望 {2} 陪我去吃 {0} 他付錢 {1}."
print(myorder.format(x, y, b))
# format的參數        0, 1, 2

字串的方法列表

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
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()Joins the elements of an iterable to the end of the 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



SVG網頁繪圖

Sorry, your browser does not support inline SVG.

SVG Tiger Head

來源: https://freesvg.org/tigers-head image/svg+xml Openclipart microugly_044482e2 2008-10-15T04:05:06 https://openclipart.org/detail/176055/Clipart-by-microugly microugly tiger face animal nocturnal zoo

留言

  1. https://hsupppppp.blogspot.com/2023/03/w3schoolsstr-format-len-slicing.html

    回覆刪除
  2. https://kuan8573.blogspot.com/2023/03/w3schoolsslicingstrlen.html

    回覆刪除
  3. https://danny1219.blogspot.com/2023/03/w3schoolsslicingstrlen.html

    回覆刪除
  4. https://michael-hou.blogspot.com/2023/03/w3schoolsstr-format-len-slicing.html

    回覆刪除
  5. https://purplefish-ouo.blogspot.com/2023/03/w3schoolsstr-format-len-slicing.html

    回覆刪除
  6. https://11117312.blogspot.com/2023/03/w3schoolsslicingstrlen.html

    回覆刪除
  7. https://takmingd11117329.blogspot.com/2023/03/w3schoolstr-format-len-slicing.html

    回覆刪除
  8. https://yu-hsi-chen7311.blogspot.com/2023/03/w3schoolsstr-format-len-slicing.html

    回覆刪除
  9. 作者已經移除這則留言。

    回覆刪除
  10. https://steven0918.blogspot.com/2023/03/w3schoolstrformatlenslicing.html

    回覆刪除
  11. https://html-css-javascript-javatang.blogspot.com/2023/03/w3schoolsslicingstrlen.html

    回覆刪除
  12. https://takmingd11117223.blogspot.com/2023/03/w3schoolstrformatlenslicing.html

    回覆刪除
  13. 作者已經移除這則留言。

    回覆刪除
  14. https://guixiu1485.blogspot.com/2023/03/htmlcssjavascriptjava.html

    回覆刪除
  15. https://jia-yi-lin.blogspot.com/2023/03/w3schoolsstr-format-len-slicing.html

    回覆刪除
  16. https://erichtml-css-javascript-java.blogspot.com/2023/03/w3schoolsstr-format-len-slicing.html

    回覆刪除
  17. https://1dth36.blogspot.com/2023/03/w3schoolstrformatlenslicing.html

    回覆刪除
  18. https://takmingd11117330.blogspot.com/2023/03/w3schoolstr-format-len-slicing.html

    回覆刪除
  19. https://d11117328.blogspot.com/2023/03/w3schoolstrformatlenslicing.html

    回覆刪除
  20. https://takmingg.blogspot.com/2023/03/w3schoolsstr-format-len-slicing.html

    回覆刪除
  21. https://html-css-javascript-html.blogspot.com/2023/03/w3schoolsstr-format-len-slicing.html

    回覆刪除
  22. https://1321354312321.blogspot.com/2023/03/w3schoolsstrformatlenslicing.html

    回覆刪除
  23. https://ling-cls.blogspot.com/2023/03/w3schoolsslicingstrlen.html

    回覆刪除
  24. https://sand456.blogspot.com/2023/03/w3schoolsstr-format-len-slicingl.html

    回覆刪除
  25. https://winnie032879.blogspot.com/2023/03/w3schoolsstr-format-len-slicing.html

    回覆刪除
  26. file:///C:/Users/User/Downloads/img_chara-face03-tora2.avif

    回覆刪除
  27. https://www.blogger.com/blog/post/edit/8406171805557929817/854472919912514917

    回覆刪除
  28. https://d10951236.blogspot.com/2023/03/w3schoolsstr-format-len-slicing.html

    回覆刪除
  29. https://pandora-mo.blogspot.com/2023/04/w3schoolsstr-format-len-slicing.html

    回覆刪除

張貼留言

這個網誌中的熱門文章

劉任昌HTML

劉任昌python自訂函數built-in內建函數math程式庫

劉任昌python字典dictionaries