On 9/10/2012 2:33 AM, Dwight Hutto wrote:


On Sun, Sep 9, 2012 at 10:41 AM, Ian Foote <i...@feete.org
<mailto:i...@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.

print(x) prints str(x), which is meant to be a 'friendly' representation. To see a difference,

>>> print(repr(3))
3
>>> print(repr('3'))
'3'

--
Terry Jan Reedy


--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to