The "," function of the print () function in python is described in detail with the "+" function 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.
PS: Let's take a look at the differences between System. out. print () and System. out. println () in java.
System. out. print (); and System. out. println ();
The former outputs no line breaks, for example:
System.out.print("a");System.out.print("b");
Result:
AB
The latter outputs a new line feed, for example:
System.out.println("a");System.out.println("b");
Result:
A
B
Summary
The above section describes the "," of the print () function in python and the System in java. out. the "+" function in the print () function is explained in detail. I hope it will help you. If you have any questions, please leave a message and I will reply to you in a timely manner. Thank you very much for your support for the help House website!