The "," function of the print () function in python is described in detail with the "+" function in the System. out. print () function in java,

Source: Internet
Author: User

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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.