从python字符串数组中删除子字符串

时间:2019-08-21 21:07:02

标签: python string

我要抓取的字符串数组看起来像str_replace("Hi, how's it going?", "(H)(i)", function(m,n) paste0(str_to_lower(m),str_to_upper(n)))

我想从数组中的每个字符串中删除["https://rotogrinders.com/players/charlie-culberson-13456?format=json", "https://rotogrinders.com/players/charlie-culberson-13456?format=json"]部分。我该怎么办?

https://rotogrinders.com/players/

1 个答案:

答案 0 :(得分:2)

您可以简单地做到:

listbase = ["https://rotogrinders.com/players/charlie-culberson-13456?format=json",
        "https://rotogrinders.com/players/charlie-culberson-13456?format=json"]
_list = [element.split("/", maxsplit=4)[-1] for element in listbase]