A tool to convert numbers (int, float) into Persian words
Project description
num2fawords
This package provides functions to convert a number (int or float) to a Persian word form.
installation
Python 3.3+ is required.
Install using pip install num2fawords command.
Usage
>>> from num2fawords import words, ordinal_words
>>> words(1984)
'یک هزار و نهصد و هشتاد و چهار'
>>> ordinal_words(1232)
'یک هزار و دویست و سی و دوم'
>>> ordinal_words(123)
'یکصد و بیست و سوم'
Obviously, words is used convert to word form and ordinal_words is for ordinal word from.
Use can also pass in floating point numbers:
>>> words(19.75)
'نوزده و هفتاد و پنج صدم'
This is the default setting. If you’d like to use “ممیز” instead of “و” for decimal point, you can:
>>> import num2fawords
>>> num2fawords.DECIMAL_SEPARATOR # default value:
' و '
>>> num2fawords.DECIMAL_SEPARATOR = ' ممیز '
>>> words(19.75)
'نوزده ممیز هفتاد و پنج صدم'
Also some people prefer, for example, “صد و هفتاد” over its other form “یکصد و هفتاد”. This library uses the second form which is the form used on official Iranian banknotes. But it can be changed:
>>> from num2fawords import HUNDREDS
>>> words(170)
'یکصد و هفتاد'
>>> HUNDREDS[1] = 'صد'
>>> words(170)
'صد و هفتاد'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file num2fawords-0.4.tar.gz.
File metadata
- Download URL: num2fawords-0.4.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f7fd0910a4a7c9b8dac3f098b454147bd9c36597e60d75bac90dc70ea8404a4
|
|
| MD5 |
be25532e88e06859211e22d372a436a1
|
|
| BLAKE2b-256 |
d0526084c5abc17803baf6ef25478bb4fe648ec4c5aff173b781ea7816ccb608
|
File details
Details for the file num2fawords-0.4-py3-none-any.whl.
File metadata
- Download URL: num2fawords-0.4-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
45ae6d25c91fa29f1847e0a3bafee55c5f1245880bf829ba45c09e073d71d0a5
|
|
| MD5 |
1e295c516ca387097b8544d085ca24a4
|
|
| BLAKE2b-256 |
6825bfbdbac958cd4e166a9f2d93d9e6f731390e5a06f151ce0c83872f9acaed
|