```

def second_to_time(second=0):

"""

传入秒数,生成字幕时间

:param second: 13

:return: 00:00:13

"""

# b = 61 # 10秒,如果是小数,只舍不入

hour_min_second = time.strftime('%H:%M:%S', time.gmtime(second))

# print(hour_min_second) # 00:00:10

return hour_min_second

```

```

def second_to_time(second_time=0.000):

"""

传入秒数,生成字幕时间

:param second_time: 6.954

:return: 00:00:06,000

"""

# 保留三位小数

second_time = round(second_time, 3)

second_list = str(second_time).split('.')

# 6

second_1 = float(second_list[0])

if len(second_list) > 1:

# 954

second_2 = second_list[1]

else:

second_2 = 000

# 00:00:06,954

hour_min_second = time.strftime('%H:%M:%S', time.gmtime(second_1))

return f"{hour_min_second},{second_2}"

```