python显示生日是星期几的方法

yipeiwu_com6年前Python基础

本文实例讲述了python显示生日是星期几的方法。分享给大家供大家参考。具体实现方法如下:

# find the day of the week of a given date
# Python will trap impossible dates like (1900, 2, 29)
# tested with Python24   vegaseat  01aug2005
from datetime import date
# a typical birthday year, month, day 
# or change it to your own birthday... 
birthday = date(1983, 12, 25)
dayList = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
# date.weekday() returns 0 for Monday and so on, so pick the day string from the dayList
print "The day of the week on %s was a %s" % (birthday.strftime("%d%b%Y"), dayList[date.weekday(birthday)])

希望本文所述对大家的Python程序设计有所帮助。

相关文章

使用python在校内发人人网状态(人人网看状态)

复制代码 代码如下:#_*_coding:utf_8_ from sgmllib import SGMLParserimport sys, urllib2, urllib, cookie...

Python使用Redis实现作业调度系统(超简单)

概述 Redis是一个开源,先进的key-value存储,并用于构建高性能,可扩展的Web应用程序的完美解决方案。 Redis从它的许多竞争继承来的三个主要特点: Redis数据库完全在...

浅谈pandas中shift和diff函数关系

通过?pandas.DataFrame.shift命令查看帮助文档 Signature: pandas.DataFrame.shift(self, periods=1, fr...

Django中celery执行任务结果的保存方法

如下所示: pip3 install django-celery-results INSTALLED_APPS = ( ..., 'django_celery_results',) #...

Django中间件基础用法详解

前言 django的中间件可以在视图函数执行前执行,比如登陆验证、日志记录等,下面简单说明一下中间件的基础用法,主要为笔者学习时的笔记 1. 在django项目文件夹下创建一个用于存放中...