Python - regex - Splitting string before word

前端 未结 4 2029
悲&欢浪女
悲&欢浪女 2021-01-22 22:21

I am trying to split a string in python before a specific word. For example, I would like to split the following string before \"path:\".

  • split strin
4条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-22 23:01

    in_str = "path:bte00250 Alanine, aspartate and glutamate metabolism path:bte00330 Arginine and proline metabolism"
    in_list = in_str.split('path:')
    print ",path:".join(in_list)[1:]
    

提交回复
热议问题