strip()是内置的字符串处理函数,其原型为
title()函数可以将字符串转换为标题格式,亦即首字母大写
s.strip(rm)
s.lstrip(rm)
s.rstrip(rm)
分别返回删除位于字符串s首尾,头部,尾部的,位于删除序列rm内的字串后的字符串,rm为空时,默认删除空白符(就是空格,回车,制表符等),听着有点拗口,举个例子来说
s='strabcdefgst'
s.strip('str')
s.lstrip('str')
s.rstrip('str')
则结果分别为
abcdefg
abcdefgst
strabcdefg
title()函数可以将字符串转换为标题格式,亦即首字母大写
例如
str=' tHe wOrLDwidE Web '
str.title()
str.title().strip()
分别返回
' The Worldwide Web '
'The Worldwide Web'
strip()顺便把首尾的空格去掉了