【python-strip】Python strip()方法

时间:2023-03-09 18:28:43
【python-strip】Python strip()方法

strip()方法用于移除字符串首尾的指定字符(默认是空格)

比如:

str = "0000000this is string example....wow!!!0000000";
print str.strip( '0' );
结果:this is string example....wow!!!
str = "0000000this is string 0000example....wow!!!0000000";
print str.strip( '0' );
结果:this is string 0000example....wow!!! 只移除首尾,不移除中间的值