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

Chris Angelico rosuav at gmail.com
Mon Mar 26 14:01:40 CEST 2012


On Mon, Mar 26, 2012 at 10:45 PM,  <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 ?

One of them takes the integer 3, converts it into a string, and prints
it. The other takes the string '3' and prints it. There's a lot of
difference under the covers, but both will print a 3, followed by a
newline.

ChrisA



More information about the Python-list mailing list