filename = 'spam.txt' filename.endswith('.txt') True filename.startswith('file:') False url = 'http://www.python.org' url.startswith('http:') True
import re url = 'http://www.python.org' re.match('http:|https:|ftp:', url) <_sre.SRE_Match object at 0x101253098>