Created
March 24, 2015 14:22
-
-
Save billyshambrook/6745e0b9c88983ff612c to your computer and use it in GitHub Desktop.
Check if string is a URL or not
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urlparse | |
def is_url(str_): | |
""" | |
Returns True if string is a URL. | |
>>> is_url('not a url') | |
False | |
>>> is_url('http://www.example.com') | |
True | |
>>> is_url('s3://bucket/hello') | |
True | |
""" | |
return bool(urlparse.urlparse(str_).scheme) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment