Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #43575

Re: howto remove the thousand separator

References <201304150257331336590@gmail.com>
Date 2013-04-14 12:06 -0700
Subject Re: howto remove the thousand separator
From Mark Janssen <dreamingforward@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.596.1365966380.3114.python-list@python.org> (permalink)

Show all headers | View raw


On Sun, Apr 14, 2013 at 11:57 AM, pyth0n3r <pyth0n3r@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

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: howto remove the thousand separator Mark Janssen <dreamingforward@gmail.com> - 2013-04-14 12:06 -0700
  Re: howto remove the thousand separator Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-04-15 00:29 +0000
    Re: howto remove the thousand separator Mark Janssen <dreamingforward@gmail.com> - 2013-04-14 17:44 -0700
      Re: howto remove the thousand separator Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-04-15 01:14 +0000
        Re: howto remove the thousand separator Chris Angelico <rosuav@gmail.com> - 2013-04-15 11:29 +1000
          Re: howto remove the thousand separator Walter Hurry <walterhurry@lavabit.com> - 2013-04-15 02:25 +0000
            Re: howto remove the thousand separator Roy Smith <roy@panix.com> - 2013-04-14 22:35 -0400
              Re: howto remove the thousand separator Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-04-15 07:04 +0000
        Re: howto remove the thousand separator Rotwang <sg552@hotmail.co.uk> - 2013-04-15 03:19 +0100
          Re: howto remove the thousand separator Ned Deily <nad@acm.org> - 2013-04-14 22:15 -0700
          Re: howto remove the thousand separator Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-04-15 07:03 +0000
            Re: howto remove the thousand separator Chris Angelico <rosuav@gmail.com> - 2013-04-15 17:39 +1000
            Re: howto remove the thousand separator Rotwang <sg552@hotmail.co.uk> - 2013-04-15 23:16 +0100

csiph-web