Jan
18
2009
0

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:

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