【发布时间】:2014-04-05 04:21:53
【问题描述】:
我想删除包含网址的字符串中的“http://”,即:“http://www.google.com”。我的代码是:
import os
s = 'http://www.google.com'
s.replace("http://","")
print s
我尝试将 http:// 替换为空格,但不知何故它仍然打印出 http://www.google.com
我是否在这里错误地使用了替换?谢谢你的回答。
【问题讨论】:
-
你也可以试试:s.split('//')[1:] or s[7:]