Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'string.': 0.05; "subject:' ": 0.07; 'subject:Python': 0.07; 'terry': 0.09; 'jan': 0.10; 'python': 0.11; 'print': 0.15; '7:45': 0.16; 'executed': 0.16; 'received:80.91': 0.16; 'received:80.91.229': 0.16; 'received:gmane.org': 0.16; 'received:list': 0.16; 'received:verizon.net': 0.16; 'reedy': 0.16; 'subject:between': 0.16; 'string': 0.18; 'wrote:': 0.21; 'produces': 0.22; 'statement': 0.22; 'header:In-Reply-To:1': 0.22; 'header:User- Agent:1': 0.23; '>>>': 0.24; 'two': 0.35; 'there': 0.35; 'header:X -Complaints-To:1': 0.36; 'received:org': 0.38; 'being': 0.39; 'to:addr:python-list': 0.39; 'to:addr:python.org': 0.40; 'between': 0.64; "'3'": 0.84; 'subject:there': 0.84; 'email addr:163.com': 0.97 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Is there any difference between print 3 and print '3' in Python ? Date: Mon, 26 Mar 2012 11:45:51 -0400 References: <5128580.32.1332762326119.JavaMail.geo-discussion-forums@pbom7> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-74-109-121-73.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20111105 Thunderbird/8.0 In-Reply-To: <5128580.32.1332762326119.JavaMail.geo-discussion-forums@pbom7> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 17 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1332776769 news.xs4all.nl 6911 [2001:888:2000:d::a6]:44670 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:22197 On 3/26/2012 7:45 AM, redstone-cold@163.com wrote: > I know the print statement produces the same result when both of > these two instructions are executed ,I just want to know Is there any > difference between print 3 and print '3' in Python ? If you want to see the difference between the number and string representation thereof, use repr(x). >>> print(repr(3), repr('3'), [3, '3']) 3 '3' [3, '3'] Note that printing a collection prints the repr() of each item precisely so one can tell the difference between the item being a number or a string. -- Terry Jan Reedy