#python-3.x
#python-3.x
Вопрос:
я хочу удалить URL типа «pic.twitter.com/zzzzz » как его удалить?
я пытался удалить URL-адреса, вот код
def remove_urls(vTEXT):
vTEXT = re.sub(r'(https|http|pic)?://(w|.|/|?|=|amp;|%)*b', '', vTEXT, flags=re.MULTILINE)
return(vTEXT)
hihi = remove_urls("this picture is belongs to pic.twitter.com, an te page is https://skype.co.id")
print(hihi)
# the result
this picture is belongs to pic.twitter.com, an te page is
итак, я хочу, чтобы результатом было то, что нам принадлежит это изображение, а страница
Ответ №1:
txt = 'Hello all please help pic.twitter.com/dgfdbf sdde'
' '.join(word for word in txt.split(' ') if not word.startswith('pic.twitter.com/'))
Комментарии:
1. Это приведет только к удалению
pic.twitter.com/
, но не к другим ссылкам.