"," Of the print () function in python and "+" in the System. out. print () function in java ",
The print () function in python and the System. out. print () function in java both have the function of printing strings.
In python:
print("hello,world!")
Output result: hello, world!
In java:
System.out.print("hello,world!");
Output result: hello, world!
We can see that the usage of these two functions is the same.
The print () function also has the following usage:
print("1+1=",1+1)
Output result: 1 + 1 = 2
Similarly, Java also has the following features:
System.out.print("1+1="+(1+1));
Output result: 1 + 1 = 2
We found that when using the print () function, we used a "," to connect the results of "1 + 1 =" and 1 + 1. ",. At the same time, when using System. out. during the print () function, we used a "+" to connect the result of "1 + 1 =" and 1 + 1. This "+" also plays a connection role.
Let's look at their output results. print () Outputs 1 + 1 = 2, and there is a space between "=" and "2", while System. out. print () Outputs 1 + 1 = 2, and there is no space between "=" and "2. Here we find that "," in the print () function in python not only serves to connect strings, but also represents a space
Summary:
1. The print () function in python serves the same purpose as the System. out. print () function in java.
2. In the print () function, "," and System. out. print () functions "+" all have the function of connecting strings.
3. In the print () function, "," also indicates a space.
4. Different Languages have many similarities, and different languages have different new features.