当前位置:  首页>> 技术小册>> Python合辑4-130个字符串操作示例

如果是 Python 中的反斜杠,则删除最后一个字符

  1. x = 'Canada\\'
  2. print(x.rstrip('\\'))

Output:

  1. Canada