1.1 KiB
1.1 KiB
title, localeTitle
| title | localeTitle |
|---|---|
| String Methods | 字符串方法 |
TODO: string基本信息
创建:
使用一对引号或撇号创建空string :
>>> new_string = ''
>>> type(new_string)
<class 'string'>
>>> len(new_string)
0
-
string.find('you')返回找到子字符串的最低位置。 -
str.join(iterable)使用指定的字符串连接iterable所有元素。 -
str.replace(old, new, max)方法用于将字符串old替换为字符串new,总计max次数。此方法返回带有替换的字符串的新副本,并且原始str不变。 -
string.split(separator, maxsplit)返回由分隔字符串的列表separator,可选maxsplit的次数,如果没有指定,该字符串将在所有情况下被分裂separator。 -
string.strip(to_strip)返回从字符串的开头和结尾删除to_strip的字符串。如果未指定to_strip,则将删除所有空白字符。