strip()方法用来删除字符串首尾的指导字符,一般默认为空格或换行符,注意:只删首尾。
代码加深印象:
str=" 111rad11ouy111 1 "
str1="111taghda11jj112111"
print(str.strip())
print(str1.strip('1'))
运行结果
111rad11ouy111 1
taghda11jj112
strip()方法用来删除字符串首尾的指导字符,一般默认为空格或换行符,注意:只删首尾。
代码加深印象:
str=" 111rad11ouy111 1 "
str1="111taghda11jj112111"
print(str.strip())
print(str1.strip('1'))
运行结果
111rad11ouy111 1
taghda11jj112