mysql - Changing list answers in python -


i've been trying input mysql table using python, thing i'm trying create list dates april 2016 can insert them individually sql insert, searched didn't find how can change value per list result (if it's 1 digit or 2 digits):

dates = ['2016-04-'+str(i+1) in range(9,30)]  

i i add 0 every time i single digit (i.e 1,2,3 etc.) , when double digit stay way (i.e 10, 11, 12 etc.)

using c style formatting, dates in april:

dates = ['2016-04-%02d'%i in range(1,31)]

need range(1,31) since last value in range not used, or use range(30) , add 1 i.

the same using .format():

dates = ['2016-04-{:02}'.format(i) in range(1,31)]


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -