Created
January 12, 2023 00:40
-
-
Save TakamiChie/a52eeb7d0379b53d360f3bc6825788d0 to your computer and use it in GitHub Desktop.
mm:ss~mm:ss を 何秒目から何秒間 表記に変換する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
t = """ | |
12:05~12:59 | |
13:01~13:25 | |
14:32~15:22 | |
""" | |
times = t.strip().split("\n") | |
for time in times: | |
s = list(map(lambda x: x.split(":"), time.split("~"))) | |
start = int(s[0][0]) * 60 + int(s[0][1]) | |
length = int(s[1][0]) * 60 + int(s[1][1]) - start | |
time = f"{start}:{length}" | |
print(time) # time,time,time などという形式にしたいときには、第二引数としてend=","とする |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment