python基础入门---strip()的用法

 

# -*- coding: UTF-8 -*-

str = "00000003210Runoob01230000000"
print(str.strip('0'))# 去除首尾字符 0
str2 = "   Runoob      "
print(str2.strip()) # 去除首尾空格


 
str = "123abcrunoob321"
print (str.strip( '12' ))  #     去除字符序列12

结果:

 

 

str = "123abcrunoob321"print(str.strip('12'))# 字符序列为 12

posted @ 2020-03-27 14:23  七九灰  阅读(356)  评论(0)    收藏  举报