python去掉首/尾/首尾空格

去掉首尾指定字符

Python strip() 方法用于移除字符串头尾指定的字符(默认为空格或换行符)或字符序列

语法:

str.strip([chars]);

如果只是去掉空格,使用

str.strip();

去掉首部指定字符

str.lstrip([chars]);

去掉尾部指定字符

str.rstrip([chars]);
原文地址:https://www.cnblogs.com/ice5/p/13991757.html