Wednesday 15 April 2015

python - Pythonic List Comprehension -


It seems like a normal task, changes some elements of the array, but my solution is not very dragon experience Does Is there a better way with an understanding of urls list?

  links = re.findall (r ("?: Https ?: // | www ..https: // www.) [\ S] +", text) if LAN ( Link) == 0: Links to link URL = [] link: If the link [0: 4] == "www.": Link = "http: //" + link urls.append (link)  

Maybe something like that

  links = re.findall (r "(?: Https ?: // | www \. Html?): // www. ) [\ S] + text, if the link == 0: return text url = map (lambda x: some (x), links)  

  ["http: //" + link if linked [0: 4] == 'www.' Links to links in other links]  

or

  [link [0: 4] == 'www.' And "http: //" + link or link]  

for links in the link: ("http: //" link if link [0: 4] ]] == 'www.' And link) - Is it like a tirey operator? In C

(link [0: 4] == 'www.' And 'http: //' + link or link ") - it has the same meaning.


On the second subject: I do a test for http: //, not for www. For example, the domain does not have to start with www.


No comments:

Post a Comment