close

how to find current day is weekday or weekends in Python?

Hello Guys, How are you all? Hope You all Are Fine. Today We Are Going To learn about how to find current day is weekday or weekends in Python in Python. So Here I am Explain to you all the possible Methods here.

Without wasting your time, Let’s start This Article.

Table of Contents

how to find current day is weekday or weekends in Python?

  1. how to find current day is weekday or weekends in Python?

    Use the date.weekday() method. Digits 0-6 represent the consecutive days of the week, starting from Monday.

  2. find current day is weekday or weekends in Python

    Use the date.weekday() method. Digits 0-6 represent the consecutive days of the week, starting from Monday.

Method 1

You can use the .weekday() method of a datetime.date object

import datetime

weekno = datetime.datetime.today().weekday()

if weekno < 5:
    print "Weekday"
else:  # 5 Sat, 6 Sun
    print "Weekend"

Method 2

Use the date.weekday() method. Digits 0-6 represent the consecutive days of the week, starting from Monday.

Conclusion

It’s all About this issue. Hope all Methods helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which Method worked for you? Thank You.

Also, Read