howto remove the thousand separator

Mark Janssen dreamingforward at gmail.com
Sun Apr 14 15:06:12 EDT 2013


On Sun, Apr 14, 2013 at 11:57 AM, pyth0n3r <pyth0n3r at gmail.com> wrote:
> I came across a problem that when i deal with int data with ',' as thousand
> separator, such as 12,916, i can not change it into int() or float().
> How can i remove the comma in int data?
> Any reply will be appreciated!!

cleaned=''
for c in myStringNumber:
   if c != ',':
     cleaned+=c
int(cleaned)

mark



More information about the Python-list mailing list