To get a character value you can use the ord(char) buildin function.
In your case, something like this should works:
strings = [u'ग',u'1ए',u'==क',u'@',u'ऊं',u'abc123',u'η',u'θ',u'abcशि']
for string in strings:
for char in string:
if ord(u'\u0900') <= ord(char) <= ord(u'\u097F'):
print(char)
The ord(char) function is available for both Python 2 and Python 3
https://docs.python.org/2.7/howto/unicode.html
Answer from Ceppo93 on Stack OverflowHow do I get the alphabet in Python?
How do I generate alphabet letters with chr()?
Does isalpha() check only English letters?
To include Unicode characters in your Python source code, you can use Unicode escape characters in the form \u0123 in your string. In Python 2.x, you also need to prefix the string literal with 'u'.
Here's an example running in the Python 2.x interactive console:
>>> print u'\u0420\u043e\u0441\u0441\u0438\u044f'
Россия
In Python 2, prefixing a string with 'u' declares them as Unicode-type variables, as described in the Python Unicode documentation.
In Python 3, the 'u' prefix is now optional:
>>> print('\u0420\u043e\u0441\u0441\u0438\u044f')
Россия
If running the above commands doesn't display the text correctly for you, perhaps your terminal isn't capable of displaying Unicode characters.
These examples use Unicode escapes (\u...), which allows you to print Unicode characters while keeping your source code as plain ASCII. This can help when working with the same source code on different systems. You can also use Unicode characters directly in your Python source code (e.g. print u'Россия' in Python 2), if you are confident all your systems handle Unicode files properly.
For information about reading Unicode data from a file, see this answer:
Character reading from file in Python
Print a unicode character in Python:
Print a unicode character directly from python interpreter:
el@apollo:~$ python
Python 2.7.3
>>> print u'\u2713'
✓
Unicode character u'\u2713' is a checkmark. The interpreter prints the checkmark on the screen.
Print a unicode character from a python script:
Put this in test.py:
#!/usr/bin/python
print("here is your checkmark: " + u'\u2713');
Run it like this:
el@apollo:~$ python test.py
here is your checkmark: ✓
If it doesn't show a checkmark for you, then the problem could be elsewhere, like the terminal settings or something you are doing with stream redirection.
Store unicode characters in a file:
Save this to file: foo.py:
#!/usr/bin/python -tt
# -*- coding: utf-8 -*-
import codecs
import sys
UTF8Writer = codecs.getwriter('utf8')
sys.stdout = UTF8Writer(sys.stdout)
print(u'e with obfuscation: é')
Run it and pipe output to file:
python foo.py > tmp.txt
Open tmp.txt and look inside, you see this:
el@apollo:~$ cat tmp.txt
e with obfuscation: é
Thus you have saved unicode e with a obfuscation mark on it to a file.