- capitalize()
Python capitalize()將字符串的第一個字母變成大寫,其他字母變小寫。對于 8 位字節編碼需要根據本地環境。
- center(width[, fillchar])
Python center() 返回一個原字符串居中,并使用空格填充至長度 width 的新字符串。默認填充字符為空格。
- count(sub[, start[, end]])
Python count() 方法用于統計字符串里某個字符出現的次數??蛇x參數為在字符串搜索的開始與結束位置。
- decode()
Python decode() 方法以 encoding 指定的編碼格式解碼字符串。默認編碼為字符串編碼。
- encode([encoding[, errors]])
Python encode() 方法以 encoding 指定的編碼格式編碼字符串。errors參數可以指定不同的錯誤處理方案。
- endswith(suffix[, start[, end]])
Python endswith() 方法用于判斷字符串是否以指定后綴結尾,如果以指定后綴結尾返回True,否則返回False??蛇x參數"start"與"end"為檢索字符串的開始與結束位置。
- expandtabs([tabsize])
Python expandtabs() 方法把字符串中的 tab 符號('\t')轉為空格,默認的空格數 tabsize 是 8。
- find(sub[, start[, end]])
Python find() 方法檢測字符串中是否包含子字符串 str ,如果指定 beg(開始) 和 end(結束) 范圍,則檢查是否包含在指定范圍內,如果包含子字符串返回開始的索引值,否則返回-1。
- format(*args, **kwargs)
格式化字符串
- index(sub[, start[, end]])
Python index() 方法檢測字符串中是否包含子字符串 str ,如果指定 beg(開始) 和 end(結束) 范圍,則檢查是否包含在指定范圍內,該方法與 python find()方法一樣,只不過如果str不在 string中會報一個異常。
- isalnum()
Python isalnum() 方法檢測字符串是否由字母和數字組成。
- isalpha()
Python isalpha() 方法檢測字符串是否只由字母組成。
- isdecimal()
Python isdecimal() 方法檢查字符串是否只包含十進制字符。這種方法只存在于unicode對象。
- isdigit()
Python isdigit() 方法檢測字符串是否只由數字組成。
- islower()
Python islower() 方法檢測字符串是否由小寫字母組成。
- isnumeric()
Python isnumeric() 方法檢測字符串是否只由數字組成。這種方法是只針對unicode對象。
- isspace()
Python isspace() 方法檢測字符串是否只由空格組成。
- istitle()
Python istitle() 方法檢測字符串中所有的單詞拼寫首字母是否為大寫,且其他字母為小寫。
- isupper()
Python isupper() 方法檢測字符串中所有的字母是否都為大寫。
- join(iterable)
Python join() 方法用于將序列中的元素以指定的字符連接生成一個新的字符串。
- ljust(width[, fillchar])
Python ljust() 方法返回一個原字符串左對齊,并使用空格填充至指定長度的新字符串。如果指定的長度小于原字符串的長度則返回原字符串。
- lower()
Python lower() 方法轉換字符串中所有大寫字符為小寫。
- lstrip([chars])
Python lstrip() 方法用于截掉字符串左邊的空格或指定字符。
- partition(sep)
partition() 方法用來根據指定的分隔符將字符串進行分割。
- replace(old, new[, count])
Python replace() 方法把字符串中的 old(舊字符串) 替換成 new(新字符串),如果指定第三個參數max,則替換不超過 max 次。
- rfind(sub[, start[, end]])
Python rfind() 返回字符串最后一次出現的位置,如果沒有匹配項則返回-1。
- rindex(sub[, start[, end]])
Python rindex() 返回子字符串 str 在字符串中最后出現的位置,如果沒有匹配的字符串會報異常,你可以指定可選參數[beg:end]設置查找的區間。
- rjust(width[, fillchar])
Python rjust() 返回一個原字符串右對齊,并使用空格填充至長度 width 的新字符串。如果指定的長度小于字符串的長度則返回原字符串。
- rpartition(sep)
Split the string at the last occurrence of sep, and return a 3-tuple containing the part before the separator, the separator itself, and the part after the separator.
- rsplit([sep[, maxsplit]])
Return a list of the words in the string, using sep as the delimiter string.
- rstrip([chars])
Python rstrip() 刪除 string 字符串末尾的指定字符(默認為空格)。
- split([sep[, maxsplit]])
Python split()通過指定分隔符對字符串進行切片,如果參數num 有指定值,則僅分隔 num 個子字符串。
- splitlines([keepends])
Python splitlines() 按照行分隔,返回一個包含各行作為元素的列表,如果 num 指定則僅切片 num 個行。
- startswith(prefix[, start[, end]])
Python startswith() 方法用于檢查字符串是否是以指定子字符串開頭,如果是則返回 True,否則返回 False。如果參數 beg 和 end 指定值,則在指定范圍內檢查。
- strip([chars])
Python strip() 方法用于移除字符串頭尾指定的字符(默認為空格)。
- swapcase
Python swapcase() 方法用于對字符串的大小寫字母進行轉換。
- title()
Python title() 方法返回"標題化"的字符串,就是說所有單詞都是以大寫開始,其余字母均為小寫(見 istitle())。
- translate(table[, deletechars])
Python translate() 方法根據參數table給出的表(包含 256 個字符)轉換字符串的字符, 要過濾掉的字符放到 del 參數中。
- upper()
Python upper() 方法將字符串中的小寫字母轉為大寫字母。
- zfill(width)
Python zfill() 方法返回指定長度的字符串,原字符串右對齊,前面填充0。