The "," of the print () function in Python and the "+" in the System.out.print () function in Java

Source: Internet
Author: User

The print () function in Python and the System.out.print () function in Java all have the function of printing strings.

In Python:

Print ("hello,world!")

The output is: hello,world!

In Java:

System.out.print ("hello,world!");

The output is: hello,world!

As we can see, the use of these two functions is the same

The print () function also has this usage:

Print ("1+1=", + +)

The output is: 1+1= 2

In the same way, Java also has:

System.out.print ("1+1=" + (+));

The output is: 1+1=2

We found that when using the print () function, we used a "," to connect the results of the "1+1=" with the result of the ",", which is the function of the connection. At the same time, when using the System.out.print () function, we used a "+" to the "1+1=" and the results of the result connected together, this "+" also plays a role in the connection

We'll see what they have. Output, print () output is 1+1= 2, "=" and "2" there is a space between, and System.out.print () output is 1+1=2, "=" and "2" there is no space between. Here we find that the "," in the print () function in Python not only acts as a connection string, but also represents a space

Summarize:

The role of the print () function in 1.python is the same as the System.out.print () function in Java

The "+" in the 2.print () function "," and the System.out.print () function have the function of a connection string

The 3.print () function "," also represents a space

4. Different languages have a lot of similarities, different languages have different new features

The "," of the print () function in Python and the "+" in the System.out.print () function in Java

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.