![](https://img2018.cnblogs.com/blog/1755589/202002/1755589-20200226094700589-994174569.png)
略
![](https://img2018.cnblogs.com/blog/1755589/202002/1755589-20200226094721124-34902636.png)
python2:
- 默认编码是ascii
- input获取的是数据本身
- bytes类型是字符串,unicode是字节
- 没有打印range(10)获取的是列表1-9
- 除法向下取整
python3:
- 默认编码unicode
- input获取的是字符串
- str是字符串,bytes是字节
- 打印range(10)是range(0,10)
- 除法返回小数
![](https://img2018.cnblogs.com/blog/1755589/202002/1755589-20200226095421410-843611409.png)
1
0
![](https://img2018.cnblogs.com/blog/1755589/202002/1755589-20200226095755945-1744840991.png)
v1:list内三个int
v2:list内三个int
v3:list内三个tuple
![](https://img2018.cnblogs.com/blog/1755589/202002/1755589-20200226100025971-74893641.png)
a = 1
b = 2
a, b = b, a
![](https://img2018.cnblogs.com/blog/1755589/202002/1755589-20200226100148003-1867130145.png)
单引号:字符串
双引号:字符串
三引号:多行注释
![](https://img2018.cnblogs.com/blog/1755589/202002/1755589-20200226100237416-2052826103.png)
is:判断两边的内存地址是否相同
==:判断两边数值是否相同
![](https://img2018.cnblogs.com/blog/1755589/202002/1755589-20200226100333254-2101043687.png)
tuple(),list()
![](https://img2018.cnblogs.com/blog/1755589/202002/1755589-20200226100400746-474036684.png)
name = "老男孩"
name[::-1]
![](https://img2018.cnblogs.com/blog/1755589/202002/1755589-20200226100723999-1077282154.png)
交集:&
并集:|
差集:-
![](https://img2018.cnblogs.com/blog/1755589/202002/1755589-20200226100924530-412915887.png)
y不等于0的情况下都成立
![](https://img2018.cnblogs.com/blog/1755589/202002/1755589-20200226101153292-700217088.png)
import copy
copy.copy(obj)
![](https://img2018.cnblogs.com/blog/1755589/202002/1755589-20200226101524849-1783816239.png)
赋值:只是将一个变量赋予了不同的变量名,相当于别名
浅拷贝:只拷贝源数据的最外层数据,共用源数据的内层数据
深拷贝:将源数据全部拷贝一份新的
![](https://img2018.cnblogs.com/blog/1755589/202002/1755589-20200226101822086-693609054.png)
占位,后续添加逻辑
![](https://img2018.cnblogs.com/blog/1755589/202002/1755589-20200226101905995-1577280193.png)
[1, 2, 4, 5, ['b', 'c', 'd'], 5]
[1, 2, 4, 5, ['b', 'c', 'd']]
[1, 2, 4, 5, ['b', 'c']]
![](https://img2018.cnblogs.com/blog/1755589/202002/1755589-20200226102258004-1572519835.png)
for i in range(10):
for j in range(1, i+1):
print('{}x{}={}'.format(i, j, i * j), end = ' ')
print('\n', end = '')
![](https://img2018.cnblogs.com/blog/1755589/202002/1755589-20200226104020979-1190983033.png)
a, b = 0, 1
while b < 100:
print (b, end = " ")
a, b = b, a + b
![](https://img2018.cnblogs.com/blog/1755589/202002/1755589-20200226110413993-896980781.png)
set()
![](https://img2018.cnblogs.com/blog/1755589/202002/1755589-20200226110438216-844300998.png)
with open('etl_log.txt', encoding = 'utf-8') as f:
for i in f:
print(i.strip())
![](https://img2018.cnblogs.com/blog/1755589/202002/1755589-20200226111312139-1008374669.png)
字典
![](https://img2018.cnblogs.com/blog/1755589/202002/1755589-20200226111340226-959715750.png)
匿名函数
![](https://img2018.cnblogs.com/blog/1755589/202002/1755589-20200226111619193-950450305.png)
*args 和 **kwargs在函数定义阶段形参的位置代表聚合,接收任意参数,在函数体内代表打散
![](https://img2018.cnblogs.com/blog/1755589/202002/1755589-20200226112209401-1476024631.png)
global
![](https://img2018.cnblogs.com/blog/1755589/202002/1755589-20200226112246841-1244057512.png)
都为高阶函数
filter:过滤
map:映射
reduce:累加
![](https://img2018.cnblogs.com/blog/1755589/202002/1755589-20200226112505040-1193541384.png)
名为lambda的函数就是匿名函数,方便
![](https://img2018.cnblogs.com/blog/1755589/202002/1755589-20200226112601356-1940507697.png)
官方说明最大深度1000,实际测试997/998
![](https://img2018.cnblogs.com/blog/1755589/202002/1755589-20200226112657967-2078214422.png)
迭代器:具有__iter__()和__next__()方法的对象称为迭代器
可迭代对象:具有__next__()方法的对象称为可迭代对象
![](https://img2018.cnblogs.com/blog/1755589/202002/1755589-20200226112925480-1975315904.png)
生成器:生成器就是程序员自己写的迭代器
![](https://img2018.cnblogs.com/blog/1755589/202002/1755589-20200226113009915-1431467227.png)
装饰器:在不改变原函数的代码及其调方式的情况下,为其添加新的功能,为装饰器
![](https://img2018.cnblogs.com/blog/1755589/202002/1755589-20200226113123099-989569859.png)
反射:使用字符串来操作对象的属性和方法
![](https://img2018.cnblogs.com/blog/1755589/202002/1755589-20200226113322947-291201890.png)
def warpper(f):
def inner(*args, **kwargs):
print('1')
ret = f(*args, **kwargs)
print('2')
return ret
return inner
@warpper
def func():
print('a')
func()
![](https://img2018.cnblogs.com/blog/1755589/202002/1755589-20200226113719134-1752378091.png)
def auth(argv):
def warpper(f):
def inner(*args, **kwargs):
if argv:
print('1')
else:
print('2')
ret = f(*args, **kwargs)
return ret
return inner
return warpper
@auth(True)
def func():
print('a')
func()
![](https://img2018.cnblogs.com/blog/1755589/202002/1755589-20200226114138978-2012835382.png)
[6, 6, 6, 6]