如何在 python 3.x 中使用 string.replace() [英] How to use string.replace() in python 3.x
本文介绍了如何在 python 3.x 中使用 string.replace()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
string.replace() 在 python 3.x 上已弃用.这样做的新方法是什么?
解决方案
和 2.x 一样,使用 str.replace()
.
示例:
<预><代码>>>>'Hello world'.replace('world', 'Guido')'你好圭多'The string.replace() is deprecated on python 3.x. What is the new way of doing this?
解决方案
As in 2.x, use str.replace()
.
Example:
>>> 'Hello world'.replace('world', 'Guido')
'Hello Guido'
这篇关于如何在 python 3.x 中使用 string.replace()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文