/ Published in: Python
No switch statement in python (http://simonwillison.net/2004/May/7/switch/)
Expand |
Embed | Plain Text
def getDaySuffix(dayNumber): if dayNumber <= 3: return {1:"st", 2:"nd", 3:"rd"}[dayNumber] else: return "th" # ex: June 12th nowTime = datetime.datetime.now() print nowTime.strftime("%B %d" + getDaySuffix(nowTime.timetuple()[2]))
You need to login to post a comment.
