Last active
October 15, 2015 15:44
-
-
Save yeondudad/858503621c74c574e113 to your computer and use it in GitHub Desktop.
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 StrNumberCommaInsert(s): | |
if s.replace('.', '').isdigit(): | |
p = 0 | |
if '.' in s: | |
p = len(s) - (s.index('.') + 1) | |
try: | |
n = int(s) | |
except ValueError: | |
n = float(s) | |
return ("{:,.%sf}" % p).format(n) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment