# -*- 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. 无法打开文件“atlsd.lib”

    问题: vs2013编译c++代码,错误 15 error LNK1104: 无法打开文件“atlsd.lib” 解决: 在你电脑或者其他人电脑上搜索atlsd.lib,将其拷贝到D:\Program ...

  2. MVC实现有关时间的进度条,使用jQuery ui的progressbar

    在电商网站中,有时候通过进度条来直观地显示用户是否到期以及用户当前的状态. 设计这样的一个Model. public class User { public int Id { get; set; } ...

  3. 报错:该字符串未被识别为有效的DateTime

    报错:该字符串未被识别为有效的DateTime □ 背景 前端的搜索条件中包含关于时间的字符串,由jquery ui的datepicker产生时间字符串. 服务端对时间做了一次转换:DateTime. ...

  4. redis分布式锁redisson

    原文:https://blog.csdn.net/Kincym/article/details/78697472 关于redisson的源代码请参考官网:https://github.com/redi ...

  5. ARC 特性

    ResultVC *myResultVC = [[ResultVC alloc]initWithNibName:@"ResultVC" bundle:nil]; [self.vie ...

  6. 【linux】linux查看文件大小,磁盘大小

    查看指定目录下 文件或目录大小超过多少的 查看 /backup/tomcat7/ 目录下 超过500M大小的文件 并展示 文件详情 find /backup/tomcat7/  -type f -si ...

  7. Struts2 无后缀action请求

    如果将Struts2的filter-mapping配置成 <filter-mapping> <filter-name>struts2</filter-name> & ...

  8. Saving HDU hdu

    话说上回讲到海东集团面临内外交困.公司的元老也仅仅剩下XHD夫妇二人了.显然.作为多年拼搏的商人,XHD不会坐以待毙的. 一天,当他正在苦思冥想解困良策的时候.突然想到了自己的传家宝,那是公司成立的时 ...

  9. winform禁用标题栏

    protected override void WndProc(ref Message m) { if (m.Msg == 0x112) { switch ((int)m.WParam) { //禁止 ...

  10. linux常用C函数目录

    字符测试篇 isalnum isalpha isascii iscntrl isdigit isgraphis islower isprint isspace ispunct isupper isxd ...