python基础

112 阅读1分钟

1.python的基本数据类型

a.Number(数字)

int(python3只有整型,没有long类型,python2中的有) 、float、 bool、complex(复数类型)

b.String(字符串)

c.List(列表)

d.Tuple(元组)

e.Dictionary(字典)

f.Set(集合)

不可变类型:Number(数字)、String(字符串)、Tuple(元组);

可变类型:List(列表)、Dictionary(字典)、Set(集合)

 

2.isinstance和type()的区别

a = isinstance([1,2,3],list)
print(a)  # True

type([1,2,3])  # list

 

3.eval()函数的作用

eval函数就是实现list、dict、tuple与str之间的转化

 

4.python3关键字

['False', 'None', 'True', 'and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']