python的布尔类型赋值_python_bomb----数据类型数值类型
1.整形
Python 2.7.5 (default, Feb 11 2014, 07:46:25)
>>> aint=3
>>> type(aint)
Python 3.6.4 (default, Aug 6 2018, 22:54:20)
>>> aint=3
>>> type(aint)
2.长整形
python2#有长整形
>>> along=1728219876932764873264934692
>>> type(along)
python3#没有长整形
>>> along=1728219876932764873264934692
>>> type(along)
3.浮点型
1.344,12000000=12e6=1.2e7=0.12e7,0.012=1.2e-2growingpains
python2
>>> afloat=12e3
>>> afloat
12000.0
>>> type(afloat)
favorite sport
python3
>>> afloat=12e3
>>> type(afloat)
四级各部分分值多少4.复数类型
acomplex=3j+8
type(acomplex)
查看帮助:可以使⽤什么⽅法,实现什么功能?
help(acomplex)
dir(acomplex)
['__abs__', '__add__', '__class__', '__coerce__', '__delattr__', '__div__', '__divmod__', '__doc__', '__eq__', '__float__', '__floordiv__',
follow
'__format__', '__ge__', '__getattribute__', '__getnewargs__', '__gt__', '__hash__', '__init__', '__int__', '__le__', '__long__', '__lt__',
'__mod__', '__mul__', '__ne__', '__neg__', '__new__', '__nonzero__', '__pos__', '__pow__', '__radd__', '__rdiv__', '__rdivmod__',
peric
'__reduce__', '__reduce_ex__', '__repr__', '__rfloordiv__', '__rmod__', '__rmul__', '__rpow__', '__rsub__', '__rtruediv__', '__tattr__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__truediv__', 'conjugate', 'imag', 'real']
>>> jugate() #共轭
(8-3j)
>>> acomplex.imag #虚部
3.0
>>> al #实部
8.0
初学阶段,避免使⽤"__"开头的内置功能
5.字符串数据类型
>>> astring="hello"
>>> type(astring)
>>> dir(astring)
['__add__', '__class__', '__contains__', '__delattr__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__',
'__getnewargs__', '__getslice__', '__gt__', '__hash__', '__init__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__',
'__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__tattr__', '__sizeof__', '__str__', '__subclasshook__',
'_formatter_field_name_split', '_formatter_parr', 'capitalize', 'center', 'count', 'decode', 'encode', 'en
dswith', 'expandtabs', 'find', 'format', 'index', 'isalnum', 'isalpha', 'isdigit', 'islower', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'partition', 'replace',knockon
'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapca', 'title', 'translate', 'upper', 'zfill']
>>> )
>>> (40,"*")
'*****************hello******************'
>>> print("学⽣管理系统".center(40,'*'))
***********学⽣管理系统***********
数据类型的转换
-在python中,所有的数据类型都可以作为内置函数,⽤来转换数据类型:
>>> int(3.10)suspended翻译
3
>>> str(3)
'3'
>>> type(str(3))
>>> float(3)
3.0
>>> complex(2)
(2+0j)
you jump i jump是什么意思如何删除内存中的变量
>>> afloat=2e12
>>> del afloat
>>> afloat
Traceback (most recent call last):
File "", line 1, in
NameError: name 'afloat' is not defined 布尔数据类型
bool:只有两个值(True,Fla)
>>>a = 1
>>> bool(a)
True
>>> bool(0)
Fal
>>> name = 'we'
>>> bool(a)
True
运算符
1.算术运算符
+,-,,*,/,%,//
2.赋值运算符
=,+=,-=,/=,%=,*=
美白护肤方法3.关系运算符
,>=,
4.逻辑运算符1 100英语
逻辑与and
逻辑或or
逻辑⾮not
python2
>>> 5/2
2
>>> 100/300
>>> 5/2.0
2.5
>>> 100/300.0
0.3333333333333333
>>> from __future__ import division >>> 5/3
1.6666666666666667
python3
vim empty.py
#判断输⼊为空时,输出"Error"
value=input("请输⼊:")
if not value:
print("Erros")