小编F P*_*cha的帖子

使用 python 中的 time() 模块判断是白天还是晚上

我开始写

import time
localtime = time.localtime()
print(localtime)
Run Code Online (Sandbox Code Playgroud)

但当地时间给出了九个属性

time.struct_time(tm_year=2018, tm_mon=7, tm_mday=31, tm_hour=22, 
                 tm_min=32, tm_sec=41, tm_wday=1, tm_yday=212, tm_isdst=1)
Run Code Online (Sandbox Code Playgroud)

我想通过将小时:分钟:秒与当地时间进行比较来确定Python中的上午还是下午。请建议

python time

1
推荐指数
1
解决办法
5709
查看次数

标签 统计

python ×1

time ×1