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>