如何检测变量的类型? [英] How to detect what type a variable is?

查看:71
本文介绍了如何检测变量的类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我想知道变量是什么类型。

例如,我得到了xml的内容但是有些内容是列表或

a字符串,我需要知道它是什么类型。


谢谢

Hi,

I want to know what type is a variable.
For example, I get the contents of an xml but some content is a list or
a string, and I need to know what type it is.

Thanks

推荐答案

2006-11-29,Leandro Ardissone< la ******** @ gmail.comwrote:
On 2006-11-29, Leandro Ardissone <la********@gmail.comwrote:

我想知道变量是什么类型的。例如,我得到了一个xml的

内容,但是一些内容是一个列表或一个字符串,并且

我需要知道它是什么类型。
I want to know what type is a variable. For example, I get the
contents of an xml but some content is a list or a string, and
I need to know what type it is.


>> x =''asdf''
type(x)
>>x = ''asdf''
type(x)



< type's'tr''>

<type ''str''>


>> i = 0
type(i)
>>i = 0
type(i)



< type''int''>

<type ''int''>


>>>
>>>



-

Grant Edwards grante哇!我知道一个笑话!!



visi.com

--
Grant Edwards grante Yow! I Know A Joke!!
at
visi.com


2006-11-29,Grant Edwards < gr **** @ visi.comwrote:
On 2006-11-29, Grant Edwards <gr****@visi.comwrote:

2006-11-29,Leandro Ardissone< la ******** @ gmail .comwrote:
On 2006-11-29, Leandro Ardissone <la********@gmail.comwrote:

>我想知道什么类型的变量。例如,我得到了xml的内容,但有些内容是列表或字符串,
我需要知道它是什么类型。
>I want to know what type is a variable. For example, I get the
contents of an xml but some content is a list or a string, and
I need to know what type it is.


>>> x =''asdf''
type(x)
>>>x = ''asdf''
type(x)


< type''str''>

<type ''str''>


>>> i = 0
type(i)
>>>i = 0
type(i)


< type''int''>

<type ''int''>



这让我想知道他是如何设法在
xml中存储Python对象的。


-

Neil Cerutti

That makes me wonder how he manages to store Python objects in
xml.

--
Neil Cerutti




Leandro Ardissone写道:

Leandro Ardissone wrote:




我想知道变量是什么类型。

例如,我得到了xml的内容但有些内容是一个列表或

a字符串,我需要知道它是什么类型。
Hi,

I want to know what type is a variable.
For example, I get the contents of an xml but some content is a list or
a string, and I need to know what type it is.



类型(可变)


肖恩

type(variable)

Sean


这篇关于如何检测变量的类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆