格式化数据方法 sanitize

#定义sanitize函数格式化数据
def sanitize(time_string):
    try:
        if '-' in time_string:                
            splitter = '-'

        elif ':' in time_string:
            splitter = ':'

        else:
            return(time_string)        #返回格式化的数据
        (mins, secs) = time_string.split(splitter)

        return(mins + '.'+secs)
    except:
        print ('values error')

 

posted @ 2018-09-05 11:01  nester_liz  阅读(264)  评论(0编辑  收藏  举报