python - Auto Serial no in my lost and found sheet -
i have sheet in serial format 24/08/2017 serial no 24 , possible next serial no 25/08/2017 using formula
as mentioned in comment, if serial number irrespective of date, can following,
with s serial number, , /
differentiates number increment , rest of serial number, can use string replace!
>>> s '100/08/2017' >>> s.replace(s.split('/')[0],str(int(s.split('/')[0])+1),1) '101/08/2017'
if serial number in date format, can use datetime module of python,
>>> datetime import datetime,timedelta >>> #serial_no = datetime.now().strftime('%d/%m/%y') >>> serial_no = "16/08/2017" >>> print serial_no 16/08/2017 >>> print (datetime.strptime(serial_no, "%d/%m/%y").date()+timedelta(days=1)).strftime('%d/%m/%y') 17/08/2017
wiki
Comments
Post a Comment