函数原型:
str.strip()
作用:删除字符串头和尾的空格,以及位于头尾的 \t之类等等
eg1:
str = ' A B C \t'
str.strip()后,结果:str = 'A B C'
eg2:
str = '0000000this is string example....wow!!!0000000';
print str.strip( '0' );
结果:this is string example....wow!!!
值得注意的是:
当str.strip()括号内为空的时候,默认删除空白符(包括'', '\r', '\t', '
')
eg3:
str = 'hello world'
print str.strip( 'hello' )
print str.strip( 'hello' ).strip()
print str.strip( ' heldo ' ).strip() #sentence 1
stt = 'h1h1h2h3h4h'
print stt.strip( 'h1' )
#sentence 2
s = '123459947855aaaadgat134f 8sfewewrf7787789879879'
str.strip()
作用:删除字符串头和尾的空格,以及位于头尾的 \t之类等等
eg1:
str = '
str.strip()后,结果:str = 'A
eg2:
str = '0000000this is string example....wow!!!0000000';
print str.strip( '0' );
结果:this is string example....wow!!!
值得注意的是:
当str.strip()括号内为空的时候,默认删除空白符(包括'', '\r',
eg3:
str = 'hello world'
print str.strip( 'hello' )
print str.strip( 'hello' ).strip()
print str.strip( ' heldo ' ).strip()
stt = 'h1h1h2h3h4h'
print stt.strip( 'h1' )
s = '123459947855aaaadgat134f
