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


Groups > comp.lang.python > #28781

Re: Is there any difference between print 3 and print '3' in Python ?

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <ian@feete.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.006
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'string.': 0.04; 'subject:Python': 0.05; 'converts': 0.07; 'executed': 0.07; "subject:' ": 0.07; 'python': 0.09; 'thx': 0.09; 'result.': 0.15; 'from:addr:ian': 0.16; 'screen,': 0.16; 'subject:between': 0.16; 'string': 0.17; 'wrote:': 0.17; 'integer': 0.17; 'produces': 0.22; 'statement': 0.23; 'header:In-Reply-To:1': 0.25; 'header:User- Agent:1': 0.26; 'received:208.97': 0.29; 'received:208.97.132': 0.29; 'received:dreamhost.com': 0.29; 'received:g.dreamhost.com': 0.29; 'print': 0.32; 'to:addr:python-list': 0.33; 'everyone': 0.33; 'there': 0.35; 'display': 0.36; 'two': 0.37; 'subject:: ': 0.38; 'object': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'between': 0.63; 'received:208': 0.63; 'subject:there': 0.65; "'3'": 0.84; 'received:208.97.132.66': 0.84; 'subject:any': 0.84; '8bit%:67': 0.93
DKIM-Signature v=1; a=rsa-sha1; c=relaxed; d=feete.org; h=message-id :date:from:mime-version:to:subject:references:in-reply-to :content-type:content-transfer-encoding; s=feete.org; bh=fz+SvCh 1J/Mzvxz8a3eW2yJM07I=; b=eoPu4A6PaqWCwZAvDlZNIGFFB4wxAgdeuQFXc+C I3r2CkN9KBab66Pno+QGZs8FdzSwb+H8b1yg8+zAbpwUPzlumzRI2QfNeCPNiO5n TDHTvM2u2PROUn+uZwYvtTcO81p+xctNUJ9n/smzNB0o/+dZ9xgGPonjkOzJSoU6 g24s=
Date Sun, 09 Sep 2012 15:41:46 +0100
From Ian Foote <ian@feete.org>
User-Agent Mozilla/5.0 (X11; Linux i686; rv:15.0) Gecko/20120827 Thunderbird/15.0
MIME-Version 1.0
To python-list@python.org
Subject Re: Is there any difference between print 3 and print '3' in Python ?
References <5128580.32.1332762326119.JavaMail.geo-discussion-forums@pbom7> <645baeaa-438e-4d30-a559-0db4231ede9c@googlegroups.com>
In-Reply-To <645baeaa-438e-4d30-a559-0db4231ede9c@googlegroups.com>
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding quoted-printable
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 <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.420.1347201717.27098.python-list@python.org> (permalink)
Lines 15
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1347201717 news.xs4all.nl 6977 [2001:888:2000:d::a6]:60407
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:28781

Show key headers only | View raw


On 09/09/12 14:23, iMath wrote:
> 在 2012年3月26日星期一UTC+8下午7时45分26秒,iMath写道:
>> 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 ?
> thx everyone

The difference is that 3 is an integer whereas '3' is a string. The 
print statement (function in python 3) converts any object to a string 
before displaying it on the screen, so print 3 and print '3' both 
display the same result.

Ian F

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


Thread

Re: Is there any difference between print 3 and print '3' in Python ? iMath <redstone-cold@163.com> - 2012-09-09 06:23 -0700
  Re: Is there any difference between print 3 and print '3' in Python ? Ian Foote <ian@feete.org> - 2012-09-09 15:41 +0100
  Re: Is there any difference between print 3 and print '3' in Python ? Benjamin Kaplan <benjamin.kaplan@case.edu> - 2012-09-09 23:55 -0700
  Re: Is there any difference between print 3 and print '3' in Python ? Terry Reedy <tjreedy@udel.edu> - 2012-09-10 03:16 -0400

csiph-web