Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >>> '{0:,}'.format(1000000)
- '1,000,000'
- >>> import locale
- >>> locale.setlocale(locale.LC_ALL, '')
- 'en_AU.utf8'
- >>> locale.format('%d', 1000000, 1)
- '1,000,000'
- >>> import locale
- >>> locale.setlocale(locale.LC_ALL, 'de_DE.utf-8')
- 'de_DE.utf-8'
- >>> locale.format('%d', 1000000, 1)
- '1.000.000'
- >>> format(1123000,',d')
- '1,123,000'
- > my_float = 123456789.123456789
- > "{:0,.2f}".format(my_float)
- '123,456,789.12'
- [[fill]align][sign][#][0][width][,][.precision][type]
- >>> from itertools import zip_longest
- >>> num = "1000000"
- >>> sep = "."
- >>> places = 3
- >>> args = [iter(num[::-1])] * places
- >>> sep.join("".join(x) for x in zip_longest(*args, fillvalue=""))[::-1]
- '1.000.000'
- i=1234567890
- s=str(i)
- str1=""
- s1=[elm for elm in s]
- if len(s1)%3==0:
- for i in range(0,len(s1)-3,3):
- str1+=s1[i]+s1[i+1]+s1[i+2]+"."
- str1+=s1[i]+s1[i+1]+s1[i+2]
- else:
- rem=len(s1)%3
- for i in range(rem):
- str1+=s1[i]
- for i in range(rem,len(s1)-1,3):
- str1+="."+s1[i]+s1[i+1]+s1[i+2]
- print str1
- 1.234.567.890
- ax=plt.gca()
- ax.get_xaxis().set_major_formatter(matplotlib.ticker.FuncFormatter(lambda x, loc: locale.format('%d', x, 1)))
Add Comment
Please, Sign In to add comment