This post is focused on python check date is Friday. I would like to show you how to check if today is Friday in python.
This article goes in detailed on how to check if today is Friday in python. this example will help you python today is Friday.
In this example, we will use DateTime library to check whether today is Friday or not. I will give you two simple examples one using weekday() and another using isoweekday(). so let’s see both examples:
You can use these examples with python3 (Python 3) version.
Table of Contents
Example 1:
main.py
from datetime import datetime
# If today is Friday (0 = Mon,1 = Tue, 2 = Wen ...)
if datetime.today().weekday() == 4:
print("Yes, Today is Friday")
else:
print("Nope...")
Output:
Yes, Today is Friday
Example 2:
from datetime import datetime
# If today is Friday (0 = Mon,1 = Tue, 2 = Wen ...)
if datetime.today().isoweekday() == 5:
print("Yes, Today is Friday")
else:
print("Nope...")
Output:
Yes, Today is Friday
I hope you like this article.🙂
Also Read :
- Top 10 VS Code extensions
- Angular Material Grid Layout Example
- Angular Material Card Example
- CSS Profile Card Design
- CSS Responsive List View Examples
- CSS Profile Card Design
- jQuery CSS Loading Animation