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程序设计有所帮助。

相关文章

tensorflow更改变量的值实例

如下所示: from __future__ import print_function,division import tensorflow as tf #create a Var...

完美解决在oj中Python的循环输入问题

完美解决在oj中Python的循环输入问题

完美解决在oj中Python的循环输入问题 这几天做题被python的循环输入问题给烦死了,好好查了一下,记录在此。 while True: t= sys.stdin.readl...

Tensorflow读取并输出已保存模型的权重数值方式

这篇文章是为了对网络模型的权重输出,可以用来转换成其他框架的模型。 import tensorflow as tf from tensorflow.python import pyw...

Django框架实现逆向解析url的方法

本文实例讲述了Django框架实现逆向解析url的方法。分享给大家供大家参考,具体如下: Django中提供了一个关于URL的映射的解决方案,你可以做两个方向的使用: ①. 有客户端的浏...

浅谈Python中的全局锁(GIL)问题

CPU-bound(计算密集型) 和I/O bound(I/O密集型) 计算密集型任务(CPU-bound) 的特点是要进行大量的计算,占据着主要的任务,消耗CPU资源,一直处于满负荷状...