Python - How to cut a string in Python?

前端 未结 6 1595
失恋的感觉
失恋的感觉 2021-02-05 04:09

Suppose that I have the following string:

http://www.domain.com/?s=some&two=20

How can I take off what is after & includin

6条回答
  •  天命终不由人
    2021-02-05 04:30

    >>str = "http://www.domain.com/?s=some&two=20"
    >>str.split("&")
    >>["http://www.domain.com/?s=some", "two=20"]
    

提交回复
热议问题