Created
December 9, 2020 17:46
-
-
Save panchishin/761a25435ddfb2d2b2e60917528b0854 to your computer and use it in GitHub Desktop.
Python change decimal places to unicode subscript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def asSubstring(number): | |
result = [] | |
decimal = False | |
for n in str(number): | |
if n == '.': | |
decimal = True | |
else: | |
result.append(chr(int(n) + 48 + 8272 * decimal)) | |
return u''.join(result) | |
asSubstring(123.456) | |
# '123₄₅₆' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment