isinstance是Python中的一个内建函数
语法:
isinstance(object, classinfo)
 
如果参数object是classinfo的实例,或者object是classinfo类的子类的一个实例, 返回True。如果object不是一个给定类型的的对象, 则返回结果总是False。
如果classinfo不表示一个类(类型对象), 那么它要么是一个类的元组, 或者递归地包含这样的(由数据类型构成的)元组.其他的序列类型是不被允许的。
如果classinfo不是一种数据类型或者由数据类型构成的元组,将引发一个TypeError异常。
 
举例:
>>> isinstance(1, int)
True
>>> isinstance(1.0, float)
True
 
>>>isinstance(a,dict)  判断对象a是否为字典,如果为真,会打印True,如为假,打印False。

Python中的isinstance函数的更多相关文章

  1. Python 中的isinstance函数

    解释: Python 中的isinstance函数,isinstance是Python中的一个内建函数 语法: isinstance(object, classinfo) 如果参数object是cla ...

  2. python --- Python中的callable 函数

    python --- Python中的callable 函数 转自: http://archive.cnblogs.com/a/1798319/ Python中的callable 函数 callabl ...

  3. Python中的super函数,你熟吗?

    摘要:经常有朋友问,学 Python 面向对象时,翻阅别人代码,会发现一个 super() 函数,那这个函数的作用到底是什么? 本文分享自华为云社区<Python中的super函数怎么学,怎么解 ...

  4. python中使用zip函数出现<zip object at 0x02A9E418>

    在Python中使用zip函数,出现<zip object at 0x02A9E418>错误的原因是,你是用的是python2点多的版本,python3.0对python做了改动 zip方 ...

  5. [转载]python中multiprocessing.pool函数介绍

    原文地址:http://blog.sina.com.cn/s/blog_5fa432b40101kwpi.html 作者:龙峰 摘自:http://hi.baidu.com/xjtukanif/blo ...

  6. Python中的map()函数和reduce()函数的用法

    Python中的map()函数和reduce()函数的用法 这篇文章主要介绍了Python中的map()函数和reduce()函数的用法,代码基于Python2.x版本,需要的朋友可以参考下   Py ...

  7. python中multiprocessing.pool函数介绍_正在拉磨_新浪博客

    python中multiprocessing.pool函数介绍_正在拉磨_新浪博客     python中multiprocessing.pool函数介绍    (2010-06-10 03:46:5 ...

  8. 举例详解Python中的split()函数的使用方法

    这篇文章主要介绍了举例详解Python中的split()函数的使用方法,split()函数的使用是Python学习当中的基础知识,通常用于将字符串切片并转换为列表,需要的朋友可以参考下   函数:sp ...

  9. python中的生成器函数是如何工作的?

    以下内容基于python3.4 1. python中的普通函数是怎么运行的? 当一个python函数在执行时,它会在相应的python栈帧上运行,栈帧表示程序运行时函数调用栈中的某一帧.想要获得某个函 ...

随机推荐

  1. ios文本常见属性

    文本属性Attributes 1.NSKernAttributeName: @10 调整字距 kerning 字距调整 2.NSFontAttributeName : [UIFont systemFo ...

  2. iOS 任意类型数据转换字符串

    //转换数据类型: NSError *parseError = nil; NSData *jsonData = [NSJSONSerialization dataWithJSONObject:resp ...

  3. HTTP头信息(转)--1

    转自:http://www.cnblogs.com/9988/archive/2012/03/21/2409086.html 我用抓包软件抓了http的包,发现accept大多数有两种情况. 第一种: ...

  4. leetcode Binary Tree Inorder Traversal python

    # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = ...

  5. 扩展VirtualBox虚拟机磁盘容量

    1. 在cmd命令行下进入VirtualBox的安装目录,使用“VBoxManage list hdds”命令,找到需要修改磁盘容量的虚拟机的img路径或UUID: VirtualBox安装目录> ...

  6. UIKit之浅析UIButton

    UIButton * button =[[UIButton alloc]init]; button.backgroundColor=[UIColor redColor]; [button setTit ...

  7. 异构数据源海量数据交换工具-Taobao DataX 下载和使用

    DataX介绍 DataX是一个在异构的数据库/文件系统之间高速交换数据的工具,实现了在任意的数据处理系统(RDBMS/Hdfs/Local filesystem)之间的数据交换. 目前成熟的数据导入 ...

  8. Oracle EBS-SQL (GL-3):从总帐追溯到发票

    SELECT je_header_id, je_line_num, trx_class_name, trx_type_name, trx_number_displayed, trx_date,comm ...

  9. 文件转换dll mingw

    MinGW:c -> o           gcc -c a.cc -> exe         gcc a.c libs.o -o a.exe (从主程序a.c,附加libs,生成a. ...

  10. mysql timestamp 值不合法问题

    Create Table: CREATE TABLE `RecruitmentDesc` ( `sn` int(11) NOT NULL AUTO_INCREMENT COMMENT '编号(自增字段 ...