如何在python中检查日期是24小时格式还是12小时格式?

问题描述 投票:-1回答:1

我有一个日期(用户输入的数据),我想识别日期是24小时还是12小时格式。我如何使用python来实现它

例如:date1 = 00:49:16:00。

我如何用python识别date1是24小时格式还是12小时格式?

python datetime-format
1个回答
0
投票

不太清楚你想实现什么。但这回答了你的问题。

date = "14:06:12:00"
if int(date[0:2]) > 12:
    print ('24 hour clock')
else:
    print ('12 hour clock')
© www.soinside.com 2019 - 2024. All rights reserved.