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 ?

Date 2012-09-09 15:41 +0100
From Ian Foote <ian@feete.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>
Newsgroups comp.lang.python
Message-ID <mailman.420.1347201717.27098.python-list@python.org> (permalink)

Show all headers | 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