小册名称:Python合辑2-字符串常用方法
5、removeprefix()
Python3.9中移除前缀的函数。
# python 3.9s = 'Arthur: three!'.removeprefix('Arthur: ')print(s)# three!
# python 3.9
s = 'Arthur: three!'.removeprefix('Arthur: ')
print(s)
# three!
和strip()相比,并不会把字符集中的字符串进行逐个匹配。