Is there a way to convert number words to Integers?

前端 未结 16 1974
北恋
北恋 2020-11-22 06:14

I need to convert one into 1, two into 2 and so on.

Is there a way to do this with a library or a class or anythi

16条回答
  •  清酒与你
    2020-11-22 06:42

    I have just released a python module to PyPI called word2number for the exact purpose. https://github.com/akshaynagpal/w2n

    Install it using:

    pip install word2number
    

    make sure your pip is updated to the latest version.

    Usage:

    from word2number import w2n
    
    print w2n.word_to_num("two million three thousand nine hundred and eighty four")
    2003984
    

提交回复
热议问题