Find this week's date in any format with python

A memorandum because I wanted a date for one week from today due to weekly batch execution.

weekly_dates.py



from datetime import datetime, timedelta

#Output one by one
for i in xrange(7):
        print (datetime.now()+timedelta(i)).strftime("%Y/%m/%d")

#Plunge into a list with list comprehension
print [(datetime.now()+timedelta(i)).strftime("%Y/%m/%d") for i in xrange(7)]


The execution result is like this.


$ python weekly_dates.py
2015/05/01
2015/05/02
2015/05/03
2015/05/04
2015/05/05
2015/05/06
2015/05/07
['2015/05/01', '2015/05/02', '2015/05/03', '2015/05/04', '2015/05/05', '2015/05/06', '2015/05/07']


Recommended Posts

Find this week's date in any format with python
format in python
Download files in any format using Python
Date manipulation in Python
List find in Python
Get date in Python
Date calculation in python
Get date with python
Date calculation in Python
Get the result in dict format with Python psycopg2
Output log in JSON format with Python standard logging
Easily format JSON in Python
Scraping with selenium in Python
Working with LibreOffice in Python
Scraping with chromedriver in python
Find the difference in Python
Debugging with pdb in Python
Working with sounds in Python
Scraping with Selenium in Python
Find permutations / combinations in Python
Tweet with image in Python
Combined with permutations in Python
String date manipulation in Python
Format json with Vim (with python)
String format with Python% operator
Let's find pi in Python
Sort by date in python
Easy with just Python! Output Graphviz figures in draw.io format!
Number recognition in images with Python
Determine the date and time format in Python and convert to Unixtime
Testing with random numbers in Python
GOTO in Python with Sublime Text 3
Scraping with Selenium in Python (Basic)
CSS parsing with cssutils in Python
Automatically format Python code in Vim
Handle GDS II format in Python
Open UTF-8 with BOM in Python
Find the Levenshtein Distance with python
Use Python in pyenv with NeoVim
Heatmap with Dendrogram in Python + matplotlib
Read files in parallel with Python
How to calculate date with python
Password generation in texto with python
Find image similarity with Python + OpenCV
Use OpenCV with Python 3 in Window
Until dealing with python in Atom
Released erajp that displays date time in Japanese calendar format in Python
Get started with Python in Blender
Working with DICOM images in Python
[Python] Format when to_csv with pandas
Note: [Python3] Convert datetime to a string in any format you like
How to get the date and time difference in seconds with python
Create and edit spreadsheets in any folder on Google Drive with python
Write documentation in Sphinx with Python Livereload
Get additional data in LDAP with python
Conversion of string <-> date (date, datetime) in Python
Spiral book in Python! Python with a spiral book! (Chapter 14 ~)
Try logging in to qiita with Python
Stress Test with Locust written in Python
Python3> in keyword> True with partial match?
Exclusive control with lock file in Python