Advertisement
shinemic

date_delta_ez.py

Nov 3rd, 2021
1,141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.43 KB | None | 0 0
  1. y, m, d = map(int, input().translate(str.maketrans(dict.fromkeys('年月日', ' '))).split())
  2. print(f'{y}年{m}月{d}日', end=' ==> ')
  3.  
  4. days = [
  5.     31, (28, 29)[(y % 4 == 0 and y % 100 != 0) or y % 400 == 0],
  6.     31, 30, 31, 30, 31, 31, 30, 31, 30, 31
  7. ]
  8.  
  9. if d + 7 > days[m - 1]:
  10.     d += 7 - days[m - 1]
  11.     if m == 12:
  12.         y += 1
  13.         m = 1
  14.     else:
  15.         m += 1
  16. else:
  17.     d += 7
  18.  
  19. print(f'{y}年{m}月{d}日')
  20.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement