giving numbers ordinal suffixes in python

前端 未结 1 621
名媛妹妹
名媛妹妹 2021-01-27 20:14

I am new to python so all help would be highly appreciated! I have learnt to use the enumerate method in my code, which gives a list tuples e.g. \'i like football\' giving the w

相关标签:
1条回答
  • 2021-01-27 21:07

    You can utilize the natural package to do this (and more).

    pip install natural
    

    Then using this code, you can print out ordinals:

    >>> from natural import number
    >>> number.ordinal(3)
    u'3rd'
    >>> number.ordinal(1234567)
    u'1234567th'
    
    0 讨论(0)
提交回复
热议问题