2004年02月25日 星期三 14:54
嘿嘿.
>>> str(type({}))==""
 True
你类型不一致如何比较
> 很弱的问题:
> 输入
> type({}), 
> 屏幕输出
> 
 > 但是输入
> type({})==""
 > 屏幕却输出 False
> 为什么会这样那?
> 我用的是activepython2.3+win2k
> 
> lilin
> lin.li at samsung.com
> Python is designed to save time
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
网易VIP收费邮箱两周年超值优惠! 满1赠6!!           http://vip.163.com
中国最大的免费邮箱在等你 25兆空间4兆附件!      http://mail.163.com
点击网易泡泡惊喜无限 全免费手机短信任你发!      http://popo.163.com
2004年02月25日 星期三 14:56
>>> a = {}
>>> isinstance(a,dict)
True
>>> a= []
>>> isinstance(a,list)
True
>>> a= (1,2,3)
>>> isinstance(a,tuple)
True
-----Original Message-----
From: Lilin [mailto:lin.li at samsung.com] 
Sent: 2004年2月25日 14:55
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
> 
> 
Zeuux © 2025
京ICP备05028076号