How to convert date to week in python

王林
Release: 2020-05-08 10:07:06
Original
6020 people have browsed it

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)
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template