How to use string.replace() in python 3.x

后端 未结 8 1901
旧巷少年郎
旧巷少年郎 2020-11-22 12:29

The string.replace() is deprecated on python 3.x. What is the new way of doing this?

8条回答
  •  北恋
    北恋 (楼主)
    2020-11-22 12:56

    As in 2.x, use str.replace().

    Example:

    >>> 'Hello world'.replace('world', 'Guido')
    'Hello Guido'
    

提交回复
热议问题