Python--2闲谈数据类型

Python 的比较操作符

  >   左边大于右边

  >=  左边大于等于右边

  <  左边小于右边

  <=  左边小于等于右边

  ==  左边等于右边

  !=  左边不等于右边

Python条件分支语法:

  if 条件 :

    条件为(True) 执行的操作

  else :

    条件为(False) 执行的操作

Python的while循环语法:

  while 条件 :

    条件为(True)执行操作

Python的数据类型

  整型类型 长整型和整型已集合成一起

  布尔类型  True == 1 False == 0

  浮点类型

  e记法 e--10浮点型

  >>>1.5e4     -> 15000.0

类型转换

  ·整型int()   字符串str()   浮点型float()

str bif做变量名存在的风险

  被赋予了新的身份,再调用str会抛异常

变量的类型 -- type()  --isinstance(arg1,arg2) 

  >>> type(True)                  --> <class 'bool' >

  >>>isinstance('abc',str)     --> True

 

posted @ 2017-08-17 23:27  110528844  阅读(145)  评论(0)    收藏  举报