Note that it will be used regularly for date-related handling.
Document is this
OK with str.zfill (width)
Don't forget that it becomes the string str.
When month
and day
are not 2 digits, fill the missing digits with 0 and output so that it becomes 2 digits
year = 2020
month = 1
day = 1
while day <= 31:
Make sure #month and day are 2 digits
yyyymmdd = str(year) + "/" + str(month).zfill(2) + "/" + str(day).zfill(2)
print(yyyymmdd)
day += 1
2020/01/01
2020/01/02
2020/01/03
2020/01/04
2020/01/05
2020/01/06
2020/01/07
2020/01/08
2020/01/09
2020/01/10
2020/01/11
2020/01/12
2020/01/13
2020/01/14
2020/01/15
2020/01/16
2020/01/17
2020/01/18
2020/01/19
2020/01/20
2020/01/21
2020/01/22
2020/01/23
2020/01/24
2020/01/25
2020/01/26
2020/01/27
2020/01/28
2020/01/29
2020/01/30
2020/01/31
Recommended Posts