python中日期格式中去掉自动补位 0

python中日期格式中去掉自动补位 0 

 

import datetime
# mac下使用 - 
time = datetime.datetime.now().strftime('%Y.%-m.%-d')
# windows使用 #
time = datetime.datetime.now().strftime('%Y.%#m.%#d')

print(time)

 

posted @ 2022-04-08 21:02  FredBrain  阅读(668)  评论(0)    收藏  举报