Python-5 数据类型、操作符

#1 数值类型:

  整型int、浮点型float(科学记数法 e 或 E)、布尔型bool

#2 字符串:

  与整型、浮点型转化:int()--截断处理 float() str()

#3 获取数据类型:

  type():

    >>> type(5.2)
    <class 'float'>

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

  isinstance():

    >>> isinstance(5.2,float)
    True
    >>> isinstance(True,bool)
    True
    >>> isinstance(True,str)
    False
    >>> isinstance('True',str)
    True

#4 操作符(运算符):

  1)+(+=)、 -(-=)、 *(*=)、 /(/=)--正常除法、 %、 **--幂运算、 //--d版除法

  2)优先级:

    幂运算:**

    正负号(一元操作符):+(正号)、-(负号)  注:**(幂运算符)比其左侧的一元操作符优先级高 且 比其右侧的一元操作符优先级低

    算术操作符:*、/、// 高于 +、-

    比较操作符:>、<、==、!=

    逻辑操作符:not 高于 and 高于 or

    

原文地址:https://www.cnblogs.com/liuhuan2368935760/p/5920822.html