python strip()
1 s = "*****egon*****" 2 print(s.strip("*"))#去除egon两边的*号
输出结果为
egon
lstrip
s = "*****egon*****" print(s.lstrip("*"))#去除egon左边的*号
输出结果为
egon*****
rstrip
s = "*****egon*****" print(s.rstrip("*"))
输出结果为
*****egon
1 s = "*****egon*****" 2 print(s.strip("*"))#去除egon两边的*号
输出结果为
egon
lstrip
s = "*****egon*****" print(s.lstrip("*"))#去除egon左边的*号
输出结果为
egon*****
rstrip
s = "*****egon*****" print(s.rstrip("*"))
输出结果为
*****egon