一. import as配合try except
try:
from greenlet import getcurrent as get_ident
except ImportError:
try:
from thread import get_ident
except ImportError:
from _thread import get_ident
参见flask的源码。按这种方式,我们在后面统一使用get_ident方法。而实际上这个get_iden方法根本就不是一个实现
二.如何在即有python27和python3的环境下,更新pip3到18.0
python3 -m pip install --upgrade pip --force-reinstall
三.python3对redis的使用操作
1.redis包安装 pip3 install redis
2.加载
四.对装饰器的理解
def canshu(id):
print ("canshu=",id)
def decorator(f,*args,**kwargs):
print("decorator=",id)
def addF(*args,**kwargs):
print("(add F")
f(*args,**kwargs)
return addF
return decorator
@canshu("1")
def testA(a,b):
print (a+b)
@canshu("2")
def testB(a,b,c):
print(a+b+c)
if __name__ == '__main__':
# app.run()
testA(1,2)
testA(1,3)
print("============================")
testB(1,2,3)
五.如何便利一个对象又不用单独一行判空
for rulefactory in rules or ():
self.add(rulefactory)
六.ubuntu如何安装python3.6.5
https://blog.csdn.net/JiekeXu/article/details/80294523