用法:
bytes.strip([chars])
bytearray.strip([chars])
返回刪除了指定的前導和尾隨字節的序列副本。
chars
參數是一個二進製序列,指定要刪除的字節值集 - 該名稱指的是該方法通常與 ASCII 字符一起使用的事實。如果省略或None
,則chars
參數默認為刪除 ASCII 空格。chars
參數不是前綴或後綴;相反,它的值的所有組合都被剝離:>>> b' spacious '.strip() b'spacious' >>> b'www.example.com'.strip(b'cmowz.') b'example'
要刪除的字節值的二進製序列可以是任何bytes-like 對象。
注意
此方法的 bytearray 版本確實
not
就地操作 - 它總是產生一個新對象,即使沒有進行任何更改。
相關用法
- Python bytes.split用法及代碼示例
- Python bytes.splitlines用法及代碼示例
- Python bytes.isupper用法及代碼示例
- Python bytes.zfill用法及代碼示例
- Python bytes.isalpha用法及代碼示例
- Python bytes.hex用法及代碼示例
- Python bytes.title用法及代碼示例
- Python bytes.isalnum用法及代碼示例
- Python bytes.removesuffix用法及代碼示例
- Python bytes.lstrip用法及代碼示例
- Python bytes.expandtabs用法及代碼示例
- Python bytes.rstrip用法及代碼示例
- Python bytes.isdigit用法及代碼示例
- Python bytes.istitle用法及代碼示例
- Python bytes.removeprefix用法及代碼示例
- Python bytes.islower用法及代碼示例
- Python bytes()用法及代碼示例
- Python bytearray()用法及代碼示例
- Python binascii.crc32用法及代碼示例
- Python base64.b64decode()用法及代碼示例
注:本文由純淨天空篩選整理自python.org大神的英文原創作品 bytes.strip。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。