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