Python core programming Note----Print

Source: Internet
Author: User

In the case of variable names only, the output string is enclosed in single quotation marks. This is so that non-string objects may also appear on the screen as characters.

The print function prints out the value of the variable.

Print is called by the Str () method. The Repr () method is called when only the variable name is used.

Proof:-------------------------------------------

Class MyClass:

def __repr__ (self):
return "repr";
def __str__ (self):
return "STR";


# The function called when testing print!

A = MyClass ();
Print "Print A:",;
Print A;

Python core programming Note----Print

Related Article

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.