Reputation: 1866
I have below filename:
pagecounts-20150802-000000
I want to extract the date out of above 20150802
I am using the below code but its not working:
print os.path.splitext("pagecounts-20150802-000000")[0]
Upvotes: 5
Views: 7810
Reputation: 28252
The methods in os.path
are mainly used for path string manipulation. You want to use string splitting:
print 'pagecounts-20150802-000000'.split('-')[1]
Upvotes: 19