Replace part of a string in Python?

前端 未结 3 1316
鱼传尺愫
鱼传尺愫 2020-11-28 12:11

I used regular expressions to get a string from a web page and part of the string may contain something I would like to replace with something else. How would it be possible

3条回答
  •  感情败类
    2020-11-28 12:56

    Use the replace() method on string:

    >>> stuff = "Big and small"
    >>> stuff.replace( " and ", "/" )
    'Big/small'
    

提交回复
热议问题