首页 > 其他 > 详细

将形如 5D, 30s 的字符串转为秒

时间:2020-04-25 01:56:57      阅读:74      评论:0      收藏:0      [点我收藏+]
import sys
def convert_to_seconds(time_str):
    # write code here
    if s in time_str:
        return float(time_str[:-1])
    elif m in time_str:
        return float(time_str[:-1]) * 60
    elif h in time_str:
        return float(time_str[:-1]) * 3600
    elif d in time_str:
        return float(time_str[:-1]) * 3600 *24
    elif D in time_str:
        return float(time_str[:-1]) * 3600 *24

while True:
    line = sys.stdin.readline()
    line = line.strip()
    if line == ‘‘:
        break
    print(convert_to_seconds(line))

2020-04-24

将形如 5D, 30s 的字符串转为秒

原文:https://www.cnblogs.com/hany-postq473111315/p/12770867.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!