一、数据类型中分为6种如下:
Number、String、List、Tuple、Sets、Dictionary
在python安装完后在python解释中输入import this
>>> import this The Zen of Python, by Tim Peters
Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren't special enough to break the rules. Although practicality beats purity. Errors should never pass silently. Unless explicitly silenced. In the face of ambiguity, refuse the temptation to guess. There should be one-- and preferably only one --obvious way to do it. Although that way may not be obvious at first unless you're Dutch. Now is better than never. Although never is often better than *right* now. If the implementation is hard to explain, it's a bad idea. If the implementation is easy to explain, it may be a good idea. Namespaces are one honking great idea -- let's do more of those! |
注意1:这是作者设计的说明。
注意2:任何语言都会对数据做一些划分,为什么要划分呢?它是为了方便管理和方便 使用,跟生活中一样,在生活中划分了很多类。
- Number(数字)
Python3支持int、float、bool、complex(复数)
Int类型是代表着整数,这个范围是无限小~无限大(注意:是根据计算机限制而定)。
Float类型是代表着小数,如:1.23等。例子如下:
a = 3.14e-10 print(a) |
bool类型是用来判断使用,表示真和假,例子如下:
a = False b = True print(a+b) |
complex类型是代表着复数,例子如下
c = 3+4j print(c) |
其他如何查看数据类型使用type函数如下
c = 4j print(type(c)) |
<class 'complex'> |
注意:复数的意思如:一个实数+负数 = 复数。