Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #66485
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ian.g.kelly@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.024 |
| X-Spam-Evidence | '*H*': 0.95; '*S*': 0.00; 'string': 0.09; 'formatting': 0.09; 'trailing': 0.09; '(default': 0.16; '9.9': 0.16; 'exponential': 0.16; 'notation': 0.16; 'specifier': 0.16; 'switches': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'feb': 0.22; '>>>': 0.22; '15,': 0.26; 'gets': 0.27; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'scale': 0.29; '(like': 0.30; 'specified': 0.30; 'message-id:@mail.gmail.com': 0.30; "skip:' 10": 0.31; 'subject:numbers': 0.31; 'url:python': 0.33; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'possible': 0.36; 'url:org': 0.36; 'behind': 0.37; 'url:library': 0.38; 'to:addr :python-list': 0.38; 'to:addr:python.org': 0.39; 'remove': 0.60; 'read': 0.60; 'url:3': 0.61; 'more': 0.64; 'hey,': 0.75; 'details:': 0.80 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=ezWDvpfNawVpVCRS58RC98UTKVS2zlk2J+tiW8BCQ3A=; b=TBKRNA8BHZHKutx5+ooEJMD2kpTmBdRk0aYpydHXm+94KCwBYz/XllXq08JibcByfC AFAKjPSv1wKMYFJzRUanloRpKOcxTOnKKuxZCa1cBBYry2Svtu3GIRQKk66HfXyExG/5 /opaU3J3PQWykILPEAYtlR9mR92jjI4DVNoe2SCZcDWvZqh3aH4IqJW3fO8zTIbffZdQ 0BX9WKDtpFMkUSop9L9HxGHxq17+BNeq9iA58AAA5p1oWwjh2HJxM+zHUADqxicLzqvE RwZ88/pDEy8c80rYwZ0vsxi63auuXALblspWWg8UZIXTRvFA1wnCyNFUjuPagTpuGFEH hlAA== |
| X-Received | by 10.68.230.137 with SMTP id sy9mr17173872pbc.126.1392500125723; Sat, 15 Feb 2014 13:35:25 -0800 (PST) |
| MIME-Version | 1.0 |
| In-Reply-To | <877d1ddd-39d8-4ede-8dff-addade1c57cd@googlegroups.com> |
| References | <833583c7-c307-4ebf-9a60-3be146a565b5@googlegroups.com> <ec88852e-1384-4aa5-834b-85135be94ab9@googlegroups.com> <mailman.6976.1392458669.18130.python-list@python.org> <ae0da085-6c41-4166-92d2-92611a990885@googlegroups.com> <mailman.6978.1392461388.18130.python-list@python.org> <df9f242f-b438-4159-b605-4be5e937aaec@googlegroups.com> <mailman.7011.1392485048.18130.python-list@python.org> <9c1b03cb-c607-4784-aaec-78616988c302@googlegroups.com> <877d1ddd-39d8-4ede-8dff-addade1c57cd@googlegroups.com> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Sat, 15 Feb 2014 14:34:45 -0700 |
| Subject | Re: decimal numbers |
| To | Python <python-list@python.org> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.7024.1392500128.18130.python-list@python.org> (permalink) |
| Lines | 16 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1392500128 news.xs4all.nl 2896 [2001:888:2000:d::a6]:54645 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:66485 |
Show key headers only | View raw
On Sat, Feb 15, 2014 at 11:57 AM, Luke Geelen <luke.geelen@gmail.com> wrote:
> hey, is it possible to remove the .0 if it is a valua without something behind the poit (like 5.0 gets 5 but 9.9 stays 9.9
The ':g' format specifier will trim off trailing zeroes, e.g.:
>>> '{:g}'.format(5.0)
'5'
It also switches to exponential notation if the scale of the number is
greater than the specified precision (default 6):
>>> '{:g}'.format(5000000.0)
'5e+06'
You can read up on string formatting for more details:
http://docs.python.org/3/library/string.html#formatstrings
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
decimal numbers luke.geelen@gmail.com - 2014-02-15 01:18 -0800
Re: decimal numbers Luke Geelen <luke.geelen@gmail.com> - 2014-02-15 01:19 -0800
Re: decimal numbers "Frank Millman" <frank@chagford.com> - 2014-02-15 12:04 +0200
Re: decimal numbers Luke Geelen <luke.geelen@gmail.com> - 2014-02-15 02:32 -0800
Re: decimal numbers "Frank Millman" <frank@chagford.com> - 2014-02-15 12:49 +0200
Re: decimal numbers Luke Geelen <luke.geelen@gmail.com> - 2014-02-15 09:17 -0800
Re: decimal numbers Ian Kelly <ian.g.kelly@gmail.com> - 2014-02-15 10:23 -0700
Re: decimal numbers Luke Geelen <luke.geelen@gmail.com> - 2014-02-15 09:42 -0800
Re: decimal numbers Luke Geelen <luke.geelen@gmail.com> - 2014-02-15 10:57 -0800
Re: decimal numbers Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-02-15 19:06 +0000
Re: decimal numbers Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-15 19:43 +0000
Re: decimal numbers Ian Kelly <ian.g.kelly@gmail.com> - 2014-02-15 14:34 -0700
Re: decimal numbers Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-16 02:30 +0000
Re: decimal numbers Chris Angelico <rosuav@gmail.com> - 2014-02-16 13:36 +1100
Re: decimal numbers "Frank Millman" <frank@chagford.com> - 2014-02-15 12:56 +0200
Re: decimal numbers Chris Angelico <rosuav@gmail.com> - 2014-02-15 21:13 +1100
Re: decimal numbers Laurent Pointal <laurent.pointal@free.fr> - 2014-02-15 15:52 +0100
Re: decimal numbers Ian Kelly <ian.g.kelly@gmail.com> - 2014-02-15 10:20 -0700
Re: decimal numbers wxjmfauth@gmail.com - 2014-02-16 04:19 -0800
csiph-web