Skip to content

Instantly share code, notes, and snippets.

@panchishin
Created December 9, 2020 17:46
Show Gist options
  • Save panchishin/761a25435ddfb2d2b2e60917528b0854 to your computer and use it in GitHub Desktop.
Save panchishin/761a25435ddfb2d2b2e60917528b0854 to your computer and use it in GitHub Desktop.
Python change decimal places to unicode subscript
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