how to split extension from path
I'm a beginner of Python. I tried to split extension. I don't know the best way. use os.path.splitext? or regexp?
In case of regexp
>>> import pre >>> p = re.compile('^.*\.(.*)') >>> m = p.match('http://www.example.com/index.html') >>> m.group(1) 'html'
Or in case of os.path.splitext
>>> import os.path >>> os.path.splitext('http://www. example.com/index.html') ('http://www. example.com/index', '.html')I like using os.path.splitext rather than regexp in this case. Any thought?
Comments