Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.06; 'variables': 0.07; 'subject:help': 0.08; 'string': 0.09; 'literal': 0.09; 'means,': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'assume': 0.14; '":"': 0.16; 'columns': 0.16; 'integer,': 0.16; 'integer.': 0.16; 'received:166.84': 0.16; 'received:166.84.1': 0.16; 'received:166.84.1.89': 0.16; 'received:mailbackend.panix.com': 0.16; 'received:panix.com': 0.16; 'roy': 0.16; 'seconds.': 0.16; 'specifier': 0.16; 'specifiers': 0.16; 'wrote:': 0.18; 'obviously': 0.18; 'variable': 0.18; 'normally': 0.19; 'received:10.0.1': 0.19; 'received:166': 0.19; 'feb': 0.22; '>>>': 0.22; 'putting': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'finally,': 0.24; 'format,': 0.24; 'integer': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'needed.': 0.30; 'url:mailman': 0.30; 'decimal': 0.31; 'another': 0.32; 'url:python': 0.33; 'trouble': 0.34; 'subject:with': 0.35; 'minutes,': 0.36; 'url:listinfo': 0.36; 'subject:?': 0.36; 'received:10.0': 0.36; 'similar': 0.36; 'url:org': 0.36; 'seconds': 0.37; 'so,': 0.37; 'two': 0.37; 'received:10': 0.37; 'pm,': 0.38; 'sure': 0.39; 'url:mail': 0.40; 'how': 0.40; 'remove': 0.60; 'header:Message-Id:1': 0.63; 'charset:windows-1252': 0.65; 'minutes': 0.67; 'smith': 0.68; 'article': 0.77; '2014,': 0.84; 'email addr:panix.com': 0.84; 'to:addr:cox.net': 0.84; 'together,': 0.84; 'same,': 0.91; 'scott': 0.93 Subject: Re: Python 2.7.6 help with white spaces? Mime-Version: 1.0 (Apple Message framework v1283) Content-Type: text/plain; charset=windows-1252 From: Roy Smith In-Reply-To: <699CF5DD-1D51-4712-900D-70B94950305A@cox.net> Date: Thu, 6 Feb 2014 23:26:37 -0500 Content-Transfer-Encoding: quoted-printable References: <699CF5DD-1D51-4712-900D-70B94950305A@cox.net> To: Scott W Dunning X-Mailer: Apple Mail (2.1283) Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 64 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1391747206 news.xs4all.nl 2858 [2001:888:2000:d::a6]:39987 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:65590 On Feb 6, 2014, at 11:12 PM, Scott W Dunning wrote: > what exactly is the =93%d:%02d=94% saying? =20 Python uses string format specifiers similar to C's printf() %d means, "convert an integer to a decimal string" %2d means the same, plus, "make the result 2 columns wide" and, finally, %02d means, "and, if it would normally be less than 2 = columns, zero-pad it on the left". So, putting that all together, we've got: "%d" --> decimal integer ":" --> a literal ":" "%02d" --> another decimal integer, this time zero-padded to two columns >=20 >=20 >=20 > On Feb 6, 2014, at 6:25 PM, Roy Smith wrote: >=20 >> In article , >> Scott W Dunning wrote: >>=20 >>> I am having trouble figuring out how to remove spaces=8A. >>>=20 >>> Assume variables exist for minutes and seconds. Each variable is an = integer.=20 >>> How would you create a string in the format, >>>=20 >>> 3:11 >>>=20 >>> with no spaces. where 3 is minutes and 11 is seconds. >>>=20 >>>=20 >>> Obviously when I=8A >>>=20 >>> print minutes, =B3:=B2, seconds >>>=20 >>> I get 3 : 11 >>>=20 >>> how can I get it to print with no spaces? =20 >>>=20 >>> 3:11 >>=20 >> print "%d:%02d" % (minutes, seconds) >>=20 >> The "02" for the seconds specifier makes sure you get exactly two=20 >> digits, with a leading zero if needed. >> --=20 >> https://mail.python.org/mailman/listinfo/python-list >=20 -- Roy Smith roy@panix.com