Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get weekday name in locale format from number in Python?

Tags:

How to get weekday name in locale format from number in Python?

It it other method to get weekday name in Python that setting date to monday and using strftime('%a') than adding timedelta(day=1).

like image 540
Chameleon Avatar asked Apr 11 '16 13:04

Chameleon


1 Answers

From this answer:

You can use

>>> import calendar
>>> dayoftheweek = 2
>>> calendar.day_name[dayoftheweek]
'Wednesday'

Where Monday = 0, Tuesday = 1 etc.

like image 137
Ryan Jackman Avatar answered Sep 28 '22 02:09

Ryan Jackman