How to Determine Name of the Day in the Week
Henry Chang
goldspin at gmail.com
Thu Sep 11 13:30:57 EDT 2008
Awesome, that worked. Thanks so much!
On Thu, Sep 11, 2008 at 10:16 AM, Fredrik Lundh <fredrik at pythonware.com>wrote:
> Henry Chang wrote:
>
> Instead of getting integers with weekday(), Monday == 0 ... Sunday == 6;
>> is there a way to get the actual names, such as "Monday ... Sunday"? I
>> would like to do this without creating a data mapping. :)
>>
>
> if you have a datetime or date object, you can use strftime with the
> appropriate formatting code. see the library reference for details.
>
> if you have the weekday number, you can use the calender module:
>
> >>> import calendar
> >>> calendar.day_name[0]
> 'Monday'
>
> (the latter also contains abbreviated day names, month names, and a bunch
> of other potentially useful functions and mappings.)
>
> </F>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080911/b049a6d0/attachment-0001.html>
More information about the Python-list
mailing list