当前位置:  首页>> 技术小册>> Python合辑2-字符串常用方法

6、removesuffix()

Python3.9中移除后缀的函数。

  1. s = 'HelloPython'.removesuffix('Python')
  2. print(s)
  3. # Hello