python去掉首尾首尾空格或指定字符

— title: python去掉首尾首尾空格或指定字符 date: 2021-09-09 14:53:46 categories:

  • IT技术
  • 编程语言
  • python tags:
  • IT技术
  • 编程语言
  • python

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

str.strip([chars]);

如果只是去掉空格,使用

str.strip();

去掉首部指定字符

str.lstrip([chars]);

去掉尾部指定字符

python去掉首尾首尾空格或指定字符

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

str.strip([chars]);

如果只是去掉空格,使用

str.strip();

去掉首部指定字符

str.lstrip([chars]);

去掉尾部指定字符

str.rstrip([chars]);
使用 Hugo 构建
主题 StackJimmy 设计