2004年02月25日 星期三 14:51
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
2004年02月25日 星期三 14:54
非常感谢 我想在程序中判断一个变量指向的是不是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 > >
2004年02月25日 星期三 15:02
从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
>
>
Zeuux © 2025
京ICP备05028076号