# 去掉字符串不需要的字符四种方法
import re
def main():
s=' abc 123 '
print(s.strip())
print(s.lstrip())
print(s.rstrip())
s = '---abc 123+++'
print( s.strip('-+'))
s='abc:123'
print(s[:3]+s[4:])
s1='\tabc\t123\txyz'
s2='\tabc\t123\txyz\ropq\r'
print(s1.replace('\t',''))
print(re.sub('[\t\r]','',s2))
# 方案4
# 加密方式abc 和xyz互换
s='abc12303023xyz'
table="".maketrans('abcxyz','xyzabc')
# 生成映射表
print(s.translate(table))
# 去掉abc
s2 = 'abc12303023xyz'
table = str.maketrans("", "", "abc")
print(s2.translate(table))







pass


main()