python将秒转换成天时分秒

    def seconds_day_hms(seconds: int):
        # print("时间换算:", seconds)
        # 分钟,秒
        m, s = divmod(seconds, 60)
        # 时,分
        h, m = divmod(m, 60)
        # 天,时
        d, h = divmod(h, 24)
        print(f"{d}天{h}时{m}分{s}秒")
        return (d, h, m, s)


版权声明:本文为wenxingchen原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。