且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在特定子字符串之后获取字符串?

更新时间:2023-02-17 08:54:58

最简单的方法可能就是拆分目标词

The easiest way is probably just to split on your target word

my_string="hello python world , i'm a beginner "
print my_string.split("world",1)[1] 

split 接受要拆分的单词(或字符)和可选的拆分次数限制.

split takes the word(or character) to split on and optionally a limit to the number of splits.

在这个例子中,在world"上拆分,并将其限制为一个拆分.

In this example split on "world" and limit it to only one split.