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

相关文章

Django ORM多对多查询方法(自定义第三张表&ManyToManyField)

对于多对多表 - 1.自定义第三张表,更加灵活 - 2.ManyToManyField 自动生成第3张表 只能 有3列数据 不能自己添加。 自定义第三张表 # models.py...

PYTHON实现SIGN签名的过程解析

PYTHON实现SIGN签名的过程解析

sign签名是用于提供给外部(第三方)调用的接口,调用方需要提供正确的appkey钥匙才能调用,确保了接口的安全性。 签名参数sign生成方法: 假设有请求参数如下: appkey...

python学习笔记:字典的使用示例详解

经典字典使用函数dict:通过其他映射(比如其他字典)或者(键,值)这样的序列对建立字典。当然dict成为函数不是十分确切,它本质是一种类型。如同list。 复制代码 代码如下:item...

在macOS上搭建python环境的实现方法

在macOS上搭建python环境的实现方法

今天刚接触python,查看了一些环境建立的文章,可能是年代久远很多都不适用,现在mac搭建python环境变得更简单。大神勿喷。 首先去python官网下载anaconda,我下载的是...

pywinauto自动化操作记事本

一、什么是pywinauto Pywinauto是基于Python开发的,用于操作Windows标准图形界面的自动化测试的脚本模块。 二、pywinauto可以用来做什么 1.可以应用在...