python_day2

python的数据类型:

1.e记法(浮点型)

>>> 1.5e10
15000000000.0

 2.字符串类型转换为整形

>>> a='90'
>>> b=int(a)
>>> b
90
>>> a='啦啦'
>>> b=int(a)
Traceback (most recent call last):
  File "<pyshell#8>", line 1, in <module>
    b=int(a)
ValueError: invalid literal for int() with base 10: '啦啦'

 3.浮点型转换为整形

>>> a=5.99
>>> c=int(a)
>>> c
5

 4.type函数:

>>> a='520'
>>> type(a)
<class 'str'>

 isinstance函数

>>> a='lala'
>>> isinstance(a,str)
True
>>> isinstance(a,int)
False

 python之常用操作符:

1.两种除法

>>> 10/8
1.25
>>> 10//8
1
>>> 3.0//2
1.0

 2.幂运算

>>> 4**2
16

 3.幂运算操作符优先级

>>> -3**2
-9
>>> 2**(-2)
0.25
>>> 2**-2
0.25
原文地址:https://www.cnblogs.com/wwq1204/p/10646693.html