whsnow 通过本文主要向大家介绍了python datetime,python datetime模块,python datetime.date,python datetime time,python datetime格式等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
Python时间格式化的时候,去掉前导0的:
dt = datetime.now()
print dt.strftime('%-H')
</div>
#结果是: '4'
在format string的%与flag之间,添加一个“-”即可。
在Mac和Linux中试过可用,不确定是否可以移植。
</div>
