strip_test_string=' 1 23 '
strip_test = strip_test_string.strip() #去除字符串前后空格
print '-'+strip_test+'-'
lstrip_test = strip_test_string.lstrip() #去除字符串前面的空格
print '-'+lstrip_test+'-'
rstrip_test = strip_test_string.rstrip() #去除字符串后面的空格
print '-'+rstrip_test+'-'
运行结果

网友评论