Home > Article > Backend Development > How to convert date to week in python
This method requires the use of the datetime library.
The example code is as follows:
from datetime import datetime week = datetime.strptime("2019-03-04","%Y-%m-%d").weekday() print(week)
The printing result is 0.
This method will return the numbers 0-6, representing Monday to Sunday in order.
Recommended tutorial: python tutorial
The above is the detailed content of How to convert date to week in python. For more information, please follow other related articles on the PHP Chinese website!