strip() 函数删除字符串首尾的指定字符
例子:str = ' dog’, cat, elephant'
str.strip(' ') #删除空格
str.strip("'") #只能删除首尾引号
split()函数对字符串按照指定字符进行切片,返回分割后的字符串列表
如果参数num 有指定值,则仅分隔 num 个子字符串
例子:
str = "this is string example....wow!!!" print (str.split( )) print (str.split('i',1))
['this', 'is', 'string', 'example....wow!!!'] ['th', 's is string example....wow!!!']