Skip to content

Python3 基本数据类型

1 - 标准数据类型

Python3 中有六个标准的数据类型:

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

1.1 Number(数字)

Python3 支持 intfloatboolcomplex(复数)。

在 Python 3 里,只有一种整数类型 int,表示为长整型,没有 python2 中的 Long。

注意:在 Python2 中是没有布尔型的,它用数字 0 表示 False,用 1 表示 True。到 Python3 中,把 True 和 False 定义成关键字了,但它们的值还是 1 和 0,它们可以和数字相加。

2 - 可变与不可变数据类型

Python3 的六个标准数据类型中:

  • 不可变数据:Number(数字)、String(字符串)、Tuple(元组);
  • 可变数据:List(列表)、Dictionary(字典)、Sets(集合)

Released under the MIT License.