Is there any difference between print 3 and print '3' in Python ?
tjreedy at udel.edu
Mon Mar 26 17:45:51 CEST 2012
On 3/26/2012 7:45 AM, redstone-cold at 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
More information about the Python-list