SHARE
TWEET

Untitled

a guest Jun 15th, 2019 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from datetime import datetime
  2. from datetime import timedelta
  3.  
  4. today = '2019-04-05'
  5.  
  6. today_number = datetime.strptime(today, '%Y-%m-%d')
  7.  
  8. before_2days = today_number - timedelta(days=2)
  9. after_2days = today_number + timedelta(days=2)
  10.  
  11. with open('input/days.txt', encoding='utf-8') as f:
  12.     for n in f:
  13.         day = datetime.strptime(n.rstrip(),"%Y-%m-%d")
  14.        
  15.         if before_2days <= day <= after_2days:
  16.             print(f"{day:%Y/%m/%d}")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top