数值数据类型

Python 的数据类型

Jason Myers

Instructor

内置数值类型

整数(Integer)

  • 整数值
  • 可表示很大数
int(123456789123456789)
123456789123456789

浮点数(Float)

  • 小数(近似)
  • 科学计数法
float(123456789123456789)
1.2345678912345678e+17
Python 的数据类型

Decimal

  • 精确表示
  • 货币计算
from decimal import Decimal
Decimal('123456789123456789')
Decimal('123456789123456789')
Python 的数据类型

打印浮点数

print(0.00001)
1e-05
print(f"{0.00001:f}")
0.000010
Python 的数据类型

打印浮点数

print(f"{0.0000001:f}")
0.000000
print(f"{0.0000001:.7f}")
0.0000001
Python 的数据类型

Python 的除法类型

4/2
2.0
4//2
2
7//3
2
Python 的数据类型

Passons à la pratique !

Python 的数据类型

Preparing Video For Download...