【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!!!

只移除首尾,不移除中间的值


 
 
原文地址:https://www.cnblogs.com/liuyl-2017/p/7852818.html