我有一个类型为../sometext/someothertext
的字符串,我正在尝试用网站名称http://www.website.com
替换字符串中的..
。
在Python中,我所做的是这样的:
strName = "../sometext/someothertext"
strName.replace("..", "http://www.website.com")
print strName
但我得到的唯一结果是
../sometext/someothertext
我也试过逃离经期,比如
strName = ../sometext/someothertext
strName.replace("\.\.", "http://www.website.com")
但产量没有变化。我该怎么做?
你没有分配结果。。。
.replace
不修改原始字符串,但返回一个带有修改的新字符串。最好指定一个替代品,以防有其他替代品。。在里面
相关问题 更多 >
编程相关推荐