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

Peter Otten __peter__ at web.de
Mon Mar 26 19:20:10 CEST 2012


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 ?

The question you really wanted to ask is: under what circumstances will the 
two statements produce different output? Here's what I found:

$ PYTHONIOENCODING=hex python -c'from __future__ import unicode_literals
print 3'
3
$ PYTHONIOENCODING=hex python -c'from __future__ import unicode_literals 
print "3"'
33
$

:)




More information about the Python-list mailing list