# -*- coding: utf-8 -*-
#python 27
#xiaodeng
#python之函数用法isinstance() #isinstance()
#说明:返回一个布尔值,判断数据类型
'''
isinstance(...)
isinstance(object, class-or-type-or-tuple) -> bool
object:一个对象
class-or-type-or-tuple:类/基本类型/元组,可以只传一个数据类型,也可以同时传递多个数据类型
bool:返回一个布尔值 Return whether an object is an instance of a class or of a subclass thereof.
With a type as second argument, return whether that is the object's type.
The form using a tuple, isinstance(x, (A, B, ...)), is a shortcut for
isinstance(x, A) or isinstance(x, B) or ... (etc.).
''' #案例
object=range(5)#list
print isinstance(object,tuple)#False
print isinstance(object,list)#True object='xiaodeng'
print isinstance(object,(str,int))#True;同时传递多个数据类型
print isinstance(object,(str,int,list))#True;同时传递多个数据类型

python之函数用法isinstance()的更多相关文章

  1. python之函数用法basestring

    # -*- coding: utf-8 -*- #python 27 #xiaodeng #python之函数用法basestring #http://www.cnblogs.com/oneday/a ...

  2. Python回调函数用法实例详解

    本文实例讲述了Python回调函数用法.分享给大家供大家参考.具体分析如下: 一.百度百科上对回调函数的解释: 回调函数就是一个通过函数指针调用的函数.如果你把函数的指针(地址)作为参数传递给另一个函 ...

  3. python之函数用法setdefault()

    # -*- coding: utf-8 -*- #python 27 #xiaodeng #python之函数用法setdefault() #D.get(k,d) #说明:k在D中,则返回 D[K], ...

  4. python之函数用法fromkeys()

    # -*- coding: utf-8 -*- #python 27 #xiaodeng #python之函数用法fromkeys() #fromkeys() #说明:用于创建一个新字典,以序列seq ...

  5. python之函数用法get()

    # -*- coding: utf-8 -*- #python 27 #xiaodeng #python之函数用法get() #http://www.runoob.com/python/att-dic ...

  6. python之函数用法capitalize()

    # -*- coding: utf-8 -*- #python 27 #xiaodeng #python之函数用法capitalize() #capitalize() #说明:将字符串的第一个字母变成 ...

  7. python之函数用法isupper()

    # -*- coding: utf-8 -*- #python 27 #xiaodeng #python之函数用法isupper() #http://www.runoob.com/python/att ...

  8. python之函数用法islower()

    # -*- coding: utf-8 -*- #python 27 #xiaodeng #python之函数用法islower() #http://www.runoob.com/python/att ...

  9. python之函数用法startswith()

    # -*- coding: utf-8 -*- #python 27 #xiaodeng #python之函数用法startswith() #http://www.runoob.com/python/ ...

随机推荐

  1. .NET:CLR via C# Assembly Loading

    基础知识 Internally, the CLR attempts to load this assembly by using the System.Reflection.Assembly clas ...

  2. JSTL fmt 格式化时间

    <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding= ...

  3. 【BZOJ】【2738】&【Tsinsen】【A1333】矩阵乘法

    整体二分+树状数组 过了[BZOJ][2527][POI2011]Meteors以后这题就没那么难啦~ 关键是[从小到大]依次插入数字,然后整体二分每个查询的第k大是在第几次插入中被插入的……嗯大概就 ...

  4. unity 3D游戏场景转换

    //////////////////2015/07/07//////// /////////////////by xbw/////////////// ///////////////环境 unity ...

  5. ffmpeg 2.3版本号, 关于ffplay音视频同步的分析

    近期学习播放器的一些东西.所以接触了ffmpeg,看源代码的过程中.就想了解一下ffplay是怎么处理音视频同步的,之前仅仅大概知道通过pts来进行同步,但对于怎样实现却不甚了解,所以想借助这个机会, ...

  6. 混沌数学之ASin模型

    相关软件:混沌数学之离散点集图形DEMO 相关代码: class ASinEquation : public DiscreteEquation { public: ASinEquation() { m ...

  7. 基于zabbix 的memached 多实例监控

    基于zabbix 的memached 多实例监控 zabbix agentd 配置文件新增配置: UserParameter=memcached.server.discovery[*],ps uax ...

  8. HDU4183 起点到终点再到起点 除起点每点仅经过一次 网络流

    题意: T个测试数据 n个圆 下面 fre x y r 表示圆的频率 坐标和半径 要求: 从频率为400(最小的) 圆 走到频率为789(最大)的圆,再走回来,除起点每个点只能经过一次 问这样的路径是 ...

  9. mysql必知必会(三、使用mysql)

    一.连接mysql数据库 mysql -u 用户名 -p回车输入密码 二.显示所有的数据库 show databases; 三.使用数据库 use 数据库名; 四.显示所有的表 show tables ...

  10. (转)深入浅出K-Means算法

    原文地址:http://www.csdn.net/article/2012-07-03/2807073-k-means 摘要:在数据挖掘中,K-Means算法是一种 cluster analysis ...