Jan
18
2009

print() in Python 3.0

In python 2.6 or below, “print” is just a simple statement to print output:

  1. print "Hello World!"
  2. print var1, var2

Now the print statement is replaced by the print() function in Python 3.0:

  1. print("Hello World!")
  2. print(var1, var2)

To suppress the trailing new line:

  1. print("Hello World!", end=" ")
  2. print("Hello World again!")

The above code will print: Hello World! Hello World again!

Reference: What’s New in Python 3.0

Written by Chris Lam in: 生活隨筆 | Tags:

No Comments »

RSS feed for comments on this post. TrackBack URL

Leave a comment

You must be logged in to post a comment.

Powered by WordPress | Aeros Theme | TheBuckmaker.com WordPress Themes