Date Ordinal Output?

后端 未结 14 1741
囚心锁ツ
囚心锁ツ 2020-11-27 06:38

I\'m wondering if there is a quick and easy way to output ordinals given a number in python.

For example, given the number 1, I\'d like to output

14条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-27 06:39

    These days I'd use Arrow http://arrow.readthedocs.io/en/latest/ (which definately wasn't around in '09)

    >>> import arrow
    >>> from datetime import datetime
    >>> arrow.get(datetime.utcnow()).format('Do')
    '27th'
    

提交回复
热议问题