Python - How to cut a string in Python?

前端 未结 6 1516
失恋的感觉
失恋的感觉 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:48

    string = 'http://www.domain.com/?s=some&two=20'
    cut_string = string.split('&')
    new_string = cut_string[0]
    print(new_string)
    

提交回复
热议问题