Return 特定字符对之间的部分字符串,在具有多个字符对的字符串中
Return part of string between specific character pair, in string with multiple character pairs
文本文件或字符串:
SomeText1/SomeText2/SomeText3/SomeText4/SomeText5
#What I am looking for:
split_func(3, "/")
>>> SomeText3
尝试:
s = "SomeText1/SomeText2/SomeText3/SomeText4/SomeText5"
# s.split("/") returns a list of strings, split at the "/"
# I.e. ["SomeText1", "SomeText2", "SomeText3", "SomeText4", "SomeText5"]
# Then take the second element (remembering that the count starts at 0
result = s.split("/")[2]
文本文件或字符串:
SomeText1/SomeText2/SomeText3/SomeText4/SomeText5
#What I am looking for:
split_func(3, "/")
>>> SomeText3
尝试:
s = "SomeText1/SomeText2/SomeText3/SomeText4/SomeText5"
# s.split("/") returns a list of strings, split at the "/"
# I.e. ["SomeText1", "SomeText2", "SomeText3", "SomeText4", "SomeText5"]
# Then take the second element (remembering that the count starts at 0
result = s.split("/")[2]