python数据类型

Python中有六大数据类型,分别是:

  • Number(数值型)
  • String(字符型)
  • List(列表)
  • Tuple(元组)
  • Sets(集合)
  • Dictionary(字典)

Number

int

长整形,比如

>>>a = 123

float

浮点数,比如

>>>b = 1.23

bool

布尔型,比如

>>>c = True
>>>d = False

complex

复数,比如

>>>e = 3.14j

List

详见列表

Tuple

详见元组

String

详见字符串

Sets

详见集合

Dictionary

详见字典

判断字符类型

可以使用type来判断字符类型,在终端输入python命令进入python的交互界面

>>>type(a)
# a 是长整形
<class 'int'>
>>>type(b)
# b 是浮点型
<class 'float'>
# c 和 d 是布尔型
>>>type(c)
<class 'bool'>
>>>type(d)
<class 'bool'>
Copyright & copy hysg 2017 all right reserved,powered by Gitbook最后修订时间(UTC+8): 2017-07-17

results matching ""

    No results matching ""