Thursday 14 July 2016

Python: Calendar: Get week day names


By using 'calendar.weekheader(n)', you can get abbreviated weekday names. n specifies the width in characters for one weekday.
>>> import calendar
>>> calendar.weekheader(0)
'      '
>>> calendar.weekheader(1)
'M T W T F S S'
>>> calendar.weekheader(2)
'Mo Tu We Th Fr Sa Su'
>>> calendar.weekheader(3)
'Mon Tue Wed Thu Fri Sat Sun'
>>> calendar.weekheader(4)
'Mon  Tue  Wed  Thu  Fri  Sat  Sun '
>>> calendar.weekheader(5)
' Mon   Tue   Wed   Thu   Fri   Sat   Sun '
>>> calendar.weekheader(6)
' Mon    Tue    Wed    Thu    Fri    Sat    Sun  '
>>> calendar.weekheader(7)


Previous                                                 Next                                                 Home

No comments:

Post a Comment