Advertisement
Guest User

CallTimers

a guest
Apr 5th, 2020
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. path = 'talk.txt'   #pathを書き換えてください
  2. with open(path,encoding='utf-8') as f:
  3.     lines = f.readlines()
  4. lines_strip = [line.strip() for line in lines]
  5. l_call = [line for line in lines_strip if '☎ 通話時間 ' in line]
  6. timeSum = 0
  7. for callLog in l_call:
  8.     timeText = callLog.split('☎ 通話時間 ')[1]
  9.     time = reversed(timeText.split(':'))
  10.     n=0
  11.     for i in time:
  12.         timeSum += int(i)*(60**n)
  13.         n+=1
  14. print(timeSum/3600,"hour")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement