python处理字符串数组慢_Python字符串处理 - str/bytes
1. str
str.count(sub[, start[, end]])
str.encode(encoding="utf-8", errors="strict")
str.format(*args, **kwargs) # s = "this is from {}".format(__file__)
str.find(sub[, start[, end]]) # 沒有查找到子串,返回-1
str.rfind(sub[, start[, end]]) # 沒有查找到子串,則報Except
str.index(sub[, start[, end]])
str.replace(old, new[, count])
str.join(iterable)
str.split(sep=None, maxsplit=-1)
str.splitlines([keepends]) # keepends: 在輸出結果里是否保留換行符('\r', '\r\n', '\n'),默認為False,不包含換行符;如果為True,則保留換行符。
str.strip([chars])
str.lstrip([chars])
str.rstrip([chars])
str.partition(sep) # 通過sep將字符串分成三部分
str.rpartition(sep)
In [85]: "what do you do wait".rpartition("do")
Out[85]: ('what do you ', 'do', ' wait')
str.expandtabs(tabsize=8) # 把字符串中的 tab 符號('\t')轉為空格
str.zfill(width) # 返回指定長度width的字符串,原字符串右對齊,前面填充0
str.upper()
str.lower()
str.islower()
c.isalpha() # 字母
c.isdecimal() # Unicode數(shù)字,,全角數(shù)字(雙字節(jié))
c.isdigit() # Unicode數(shù)字,byte數(shù)字(單字節(jié)),全角數(shù)字(雙字節(jié)),羅馬數(shù)字
c.isnumeric() # Unicode數(shù)字,全角數(shù)字(雙字節(jié)),羅馬數(shù)字,漢字數(shù)字
str.startswith(prefix[, start[, end]])
str.endswith(suffix[, start[, end]])
eval(source[, globals[, locals]]) # 將str作為有效表達式并返回結果
2. bytes / bytearray
classmethod
fromhex(string)
encode()
bytes.count(sub[, start[, end]])
bytes.decode(encoding="utf-8", errors="strict")
bytearray.decode(encoding="utf-8", errors="strict")
bytes.find(sub[, start[, end]])
bytearray.find(sub[, start[, end]])
bytes.join(iterable)
bytearray.join(iterable)
bytes.replace(old, new[, count])
bytearray.replace(old, new[, count])
bytes.startswith(prefix[, start[, end]])
bytearray.startswith(prefix[, start[, end]])
3. printf-style String Formatting
總結
以上是生活随笔為你收集整理的python处理字符串数组慢_Python字符串处理 - str/bytes的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: antd 表格树如何展开_如何分析工作,
- 下一篇: 电视剧网络点击率排行榜TOP10 猜猜看