爬虫中时间有xx分钟转换成格式化

    timeLen = "100分钟"    
    if "分钟" in timeLen:
       timeLen = int(timeLen.replace("分钟", ""))
       hour = str(timeLen // 60)
       minutes = str(timeLen % 60) if len(str(timeLen % 60)) == 2 else ("0" + str(timeLen % 60))
       timeLen = ":".join((hour, minutes, "00"))

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章