Python论坛  - 讨论区

标题:[python-chinese] about type()

2004年02月25日 星期三 14:51

zhao bear_sh at eastday.com
Wed Feb 25 14:51:26 HKT 2004

Lilin,您好!
  只是结果对象的字符串显示方法

  而type({})==""却是一个结果对象与一个string对象的比较,结果当然是false的
	

======= 2004-02-25 14:42:03 您在来信中写道:=======

>很弱的问题:
>输入
>type({}), 
>屏幕输出
>
>但是输入
>type({})==""
>屏幕却输出 False
>为什么会这样那?
>我用的是activepython2.3+win2k
>
>lilin
>lin.li at samsung.com
>Python is designed to save time_______________________________________________
>python-chinese mailing list
>python-chinese at lists.python.cn
>http://python.cn/mailman/listinfo/python-chinese

= = = = = = = = = = = = = = = = = = = =
			

        致
礼!
 
				 
        zhao
        bear_sh at eastday.com
          2004-02-25


[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2004年02月25日 星期三 14:54

Lilin lin.li at samsung.com
Wed Feb 25 14:54:44 HKT 2004

非常感谢
我想在程序中判断一个变量指向的是不是Dict应该怎么作呢
if type(variable)==???
.........

lilin
lin.li at samsung.com
Python is designed to save time
----- Original Message ----- 
From: "zhao" <bear_sh at eastday.com>
To: "Lilin" <lin.li at samsung.com>
Cc: "python-chinese" <python-chinese at lists.python.cn>
Sent: Wednesday, February 25, 2004 2:51 PM
Subject: Re: [python-chinese] about type()


> Lilin,您好!
>   只是结果对象的字符串显示方法
> 
>   而type({})==""却是一个结果对象与一个string对象的比较,结果当然是false的
> 
> 
> ======= 2004-02-25 14:42:03 您在来信中写道:=======
> 
> >很弱的问题:
> >输入
> >type({}), 
> >屏幕输出
> >
> >但是输入
> >type({})==""
> >屏幕却输出 False
> >为什么会这样那?
> >我用的是activepython2.3+win2k
> >
> >lilin
> >lin.li at samsung.com
> >Python is designed to save time_______________________________________________
> >python-chinese mailing list
> >python-chinese at lists.python.cn
> >http://python.cn/mailman/listinfo/python-chinese
> 
> = = = = = = = = = = = = = = = = = = = =
> 
> 
>         致
> 礼!
>  
> 
>         zhao
>         bear_sh at eastday.com
>           2004-02-25
> 
> 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2004年02月25日 星期三 15:02

Qiangning Hong lucifer at tsinghua.org.cn
Wed Feb 25 15:02:18 HKT 2004

从Python2.2开始,the preferred way to 判断一个变量是不是built-in类型的方法
是:
isinstance(variable, type)

在你的情况为
isinstance({}, dict)

-----Original Message-----
From: python-chinese-bounces at lists.python.cn
[mailto:python-chinese-bounces at lists.python.cn] On Behalf Of Lilin
Sent: Wednesday, February 25, 2004 2:55 PM
To: python-chinese at lists.python.cn
Subject: Re: [python-chinese] about type()

非常感谢
我想在程序中判断一个变量指向的是不是Dict应该怎么作呢
if type(variable)==???
.........

lilin
lin.li at samsung.com
Python is designed to save time
----- Original Message ----- 
From: "zhao" <bear_sh at eastday.com>
To: "Lilin" <lin.li at samsung.com>
Cc: "python-chinese" <python-chinese at lists.python.cn>
Sent: Wednesday, February 25, 2004 2:51 PM
Subject: Re: [python-chinese] about type()


> Lilin,您好!
>   只是结果对象的字符串显示方法
> 
>   而type({})==""却是一个结果对象与一个string对象的比较,结果
当然是false的
> 
> 
> ======= 2004-02-25 14:42:03 您在来信中写道:=======
> 
> >很弱的问题:
> >输入
> >type({}), 
> >屏幕输出
> >
> >但是输入
> >type({})==""
> >屏幕却输出 False
> >为什么会这样那?
> >我用的是activepython2.3+win2k
> >
> >lilin
> >lin.li at samsung.com
> >Python is designed to save
time_______________________________________________
> >python-chinese mailing list
> >python-chinese at lists.python.cn
> >http://python.cn/mailman/listinfo/python-chinese
> 
> = = = = = = = = = = = = = = = = = = = =
> 
> 
>         致
> 礼!
>  
> 
>         zhao
>         bear_sh at eastday.com
>           2004-02-25
> 
> 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2024

    京ICP备05028076号