I have a file name:
pagecounts-20150802-000000
I want to extract the date from above. 20150802 I use the code below, but its not working:
20150802
print os.path.splitext("pagecounts-20150802-000000")[0]
Methods are os.pathmainly used to manipulate a path string. You want to use line splitting:
os.path
print 'pagecounts-20150802-000000'.split('-')[1]
Source: https://habr.com/ru/post/1608225/More articles:iPython - setting magic commands in a configuration file - pythonHow can I check in bootstrap that at least one checkbox is checked and pass this information to php? - javascriptSpring Security Protection Filter on Zuul for Creating and Sharing a Session - springCheck if UTF-8 is a vowel in MATLAB - stringCan I change SOCKS proxies within a function using SocksiPy? - pythonWhy are imported functions called so indirectly in Linux? - linuxHow to avoid template template when calling parent constructor - c ++Javascript / angular - Scrolling an array back with forEach - javascriptBase64 encoding or random string bin2hex - stringWhen deploying a Windows IoT application, an application activation error occurs locally - c #All Articles