Python knowledge point summary (isinstance (), pythonisinstance

Source: Internet
Author: User

Python knowledge point summary (isinstance (), pythonisinstance

1. isinstance (object, type) Function

This function has two parameters. The first parameter is an object, and the second parameter is a known data type.

This function is used to determine whether an object is of a known type. If yes, True is returned. If not, False is returned.

The following is an example of a test:

Z = 1
Print (isinstance (z, int ))
Print (isinstance (z, str ))
Print (isinstance (z, (str, int, float )))
Z1 = [1, 2, 3, 53, 46, 5]
Print (isinstance (z1, list ))
Z2 =)
Print (isinstance (z2, tuple ))
Z3 = set (list ([32132,3213, 1223,123,212, 1322,245,])
Print (isinstance (z3, set ))

Result:

True
False
True
True
True
True

 

 

 

 

 

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.