有时候我们需要知道variable的数据类型,在python中有内置函数type可以获取variable的数据类型
1. 在console输入如下code:
id = 1
type(id)
输出:<type 'int'>
2. 在console输入如下code:
id = 1L
type(id)
输出:<type 'long'>
3. 在console输入如下code:
id = 1.0
type(id)
输出:<type 'float'>
有时候我们需要知道variable的数据类型,在python中有内置函数type可以获取variable的数据类型
1. 在console输入如下code:
id = 1
type(id)
输出:<type 'int'>
2. 在console输入如下code:
id = 1L
type(id)
输出:<type 'long'>
3. 在console输入如下code:
id = 1.0
type(id)
输出:<type 'float'>