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

Dwight Hutto dwightdhutto at gmail.com
Mon Sep 10 02:33:52 EDT 2012


On Sun, Sep 9, 2012 at 10:41 AM, Ian Foote <ian at feete.org> wrote:

> 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
>>
>
>
Here's a future import though I used,so I can use the planned 3 with a 2x
python version in the command line interpreter:

Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\david>c:\python26\python.exe
Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit
(Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()

C:\Users\david>c:\python27_64\python.exe
Python 2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit (AMD64)]
on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import __future__
>>> x = 3
>>> y = '3'
>>> print(x)
3
>>> print(y)
3
>>>
>>> type(x)
<type 'int'>
>>> type(y)
<type 'str'>

>>> z = '%i' % (3)
>>> type(z)
<type 'str'>
>>>

In other words type(value), and find out the difference.
-- 
Best Regards,
David Hutto
*CEO:* *http://www.hitwebdevelopment.com*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120910/d701bd58/attachment.html>


More information about the Python-list mailing list