为什么在Python3中使用strip()方法后字符串中的某些字符会莫名消失?
具体的代码如下:
input = "Please convert 899999999999 using AaBbCcDdEeFfGgHhIiJjKkaaaaLlaaa "
output = input.strip('Please convert')
print(output)
899999999999 using AaBbCcDdEeFfGgHhIiJjKkaaaaL
有没有人能解释一下?
1 个回答
0
strip()
这个函数会去掉字符串开头和结尾的所有字符,而不是去掉你输入的那些字符。
https://docs.python.org/3/library/stdtypes.html#str.strip
换句话说,'acelnorstvP '
这个字符串处理后得到的结果是一样的。