python顯示生日是星期幾的方法
更新時間:2015年05月27日 12:46:39 作者:依山帶水
這篇文章主要介紹了python顯示生日是星期幾的方法,涉及Python使用date模塊操作日期的技巧,需要的朋友可以參考下
本文實例講述了python顯示生日是星期幾的方法。分享給大家供大家參考。具體實現(xiàn)方法如下:
# 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程序設(shè)計有所幫助。
相關(guān)文章
pdf論文中python畫的圖Type 3 fonts字體不兼容的解決方案
這篇文章主要介紹了pdf論文中python畫的圖Type 3 fonts字體不兼容的解決方案,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2021-04-04使用python爬取連續(xù)降水數(shù)據(jù)信息實例
這篇文章主要為大家介紹了使用python提取連續(xù)降水數(shù)據(jù)信息實現(xiàn)示例,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2024-01-01Python中enumerate()函數(shù)編寫更Pythonic的循環(huán)
本篇文章主要大家通過實例講述了Python中enumerate()函數(shù)編寫更Pythonic的循環(huán)的知識點,有興趣的朋友參考學習下。2018-03-03