lstrip = left strip =去除(字符串)左边的=stip leading=去除(字符串)开始的
rstrip = right strip =去除(字符串)右边的=strip trailling=去除(字符串)末尾的
strip = stip left and right = 去除(字符串的)左边的和右边的=strip leading and trailing = 去除(字符串)开始的和末尾的
默认为白空格Whitespace。
所谓的白空格,一般指的是:
空格本身,回车\r,换行\n,制表符\t, 换页符\f
(对应于正则表达式中的: \s == [ \r\n\t\f] )
#!/usr/bin/python
str = " this is string example....wow!!! ";
print str.rstrip();
str = "88888888this is string example....wow!!!8888888";
print str.rstrip('8');
以上实例输出结果如下:
this is string example....wow!!! 88888888this is string example....wow!!!