Python基本数据类型

Python基本数据类型

内置数据类型BIDT(built-in data type)

 Python内置许多数据基本类型。

数据类型DT表示形式
int整形如:-1,0,1,…
float浮点型如:-1.1,0.0,1.1,…
str字符串如–单引号或双引号括起来的形式 “hello”, ‘python’
list列表如:[1,2], 嵌套列表[1,[2,3]]
tuple元组如:(1,2)
set无序列表如:{1,2,3,4}
complex数学中的复数(如果你还记得的话—中学记忆)如:1+2j
dict字典(不就是json对象形式吗?)如:{“name”:”东陆之滇”,”addr”:”翠湖畔”}
bool布尔类型如:值有两个True、False

 使用BIF(Python内置函数)—type(var)可以查看变量(或常量)var的数据类型。

>>> type(1)
<class 'int'>
>>> type(1.2)
<class 'float'>
>>> type("ss")
<class 'str'>
>>> type([1,2])
<class 'list'>
>>> type((1,2))
<class 'tuple'>
>>> type({1,2})
<class 'set'>
>>> type(1+2j)
<class 'complex'>
>>> type({"name":"东陆之滇","addr":"翠湖畔"})
<class 'dict'>
>>>> type(True)
<class 'bool'>
>>> type(False)
<class 'bool'>
posted @ 2016-07-13 11:52  IT当时语_青山师  阅读(3)  评论(0编辑  收藏  举报  来源