Consider the following two Python code snippets from Python 2.x.
# Code 1 print 1 # Output: 1
# Code 2 print(1) # Output: 1
In the case of a single variable in Python 2. Group".
Example:
# Code 3 print 1, 2 # Output: 1 2
# Code 4 print (1, 2) # Output: (1, 2)
Note:
In Python 3.0, the print statement was changed to the print() function. Below is the equivalent code in Python 3.0.
# Equivalent codes in Python 3.0 # (Produces same output) # Code 1: print(1) # Output: 1 # Code 2 : print((1)) # Output: 1 # Code 3: print(1, 2) # Output: 1 2 # Code 4: print((1, 2)) # Output: (1, 2)
Related recommendations: "Python Tutorial"
This article is an introduction to how to print single and multiple variables in Python. I hope it will be useful to friends who need it. Helped!
The above is the detailed content of How to print single and multiple variables in Python?. For more information, please follow other related articles on the PHP Chinese website!