python入门学习(四 Package以及数据类型)

1,Python自带(build-in)package(主要用import导入)和外部(external)package

  1.1自带package举例: os包;  os.getwd()

2.利用easy_install和pip 来安装扩展文件

  2.1 例如 pip install request(s)

 

3.python 数据类型

  3.1 总体上讲: numerics,sequesences,mappings,classes,instances,exceptions.

  3.2 Numerics Types: int (包含Boolean),float,complex(复数行)

   int:unlimited length;

  float 使用C的double实现利用sys.float_info;可以查看

  complex: real(实部) imaginary(虚部) 分别用z.real和z.img来区分两部分

具体参见:https://docs.python.org/3/libary/stdtypes.html#numberic-types-int-float-complex

'''
Created on 201711

@author: Kevin
'''
import sys

a = 3
b = 4

c = 5.5
d = 6.5

e = complex(c,d)
f = complex(float(a),float(b))

print("a is type: ",type(a)) #type 是查看数据类型
print("a is type: ",type(c)) #type 是查看数据类型
print("a is type: ",type(e)) #type 是查看数据类型

print(a+b) #
print(d/c) #
print(b/a) #
print(b//a) #两个除号四舍五入取整

print(e)
print(e+f)

print(sys.float_info)#float的具体信息
a is type:  <class 'int'>
a is type:  <class 'float'>
a is type:  <class 'complex'>
7
1.1818181818181819
1.3333333333333333
1
(5.5+6.5j)
(8.5+10.5j)
sys.float_info(max=1.7976931348623157e+308, max_exp=1024, max_10_exp=308, min=2.2250738585072014e-308, min_exp=-1021, min_10_exp=-307, dig=15, mant_dig=53, epsilon=2.220446049250313e-16, radix=2, rounds=1)

 

posted @ 2017-11-29 17:47  KvienChen  阅读(425)  评论(0编辑  收藏  举报