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
Post a Comment