21-removeprefix/removesuffix:匹配才移除
语法讲解
今天学: removeprefix / removesuffix
s = "https://example.com"
print(s.removeprefix("https://"))
t = "file.txt"
print(t.removesuffix(".txt"))
小练习
运行下面代码后输出是什么?(多行输出请按真实换行提交)
s = "https://example.com"
print(s.removeprefix("https://"))
t = "file.txt"
print(t.removesuffix(".txt"))
提交要求: 只提交最终输出结果,不要添加多余的说明或引号。
全部评论