随笔分类 - Python
摘要:官网 https://pyjwt.readthedocs.io/en/latest/index.html # 官网 https://pyjwt.readthedocs.io/en/latest/index.html # 我们在jwt.encode函数中使用了三个参数: # 1)第一个是payload
阅读全文
摘要:一、发现之前没有线程的日志,写了一个简单的,参考来源:https://www.cnblogs.com/vamei/archive/2012/10/11/2720042.html import threading def demo(i): print("线程名",i) try: i = 0 # 开启线
阅读全文
摘要:之前有一篇介绍到装饰器:https://www.cnblogs.com/yinwenbin/p/10547058.html 本篇主要是收集常用装饰器的用法(参考https://www.runoob.com/python/python-built-in-functions.html) 1、classm
阅读全文
摘要:1、地址: https://www.cnblogs.com/vamei/archive/2012/08/31/2661870.html 正则表达式的函数 r = re.compile(pattern) #如果一个正则表达式要重复使用几千次,出于效率的考虑,我们应该先把这个正则先预编译好 e = re
阅读全文
摘要:一、巧用eval data = {"1": {"2": {"3": "测试"}}} def aaa(*args): a = "data{}".format(''.join(['["{}"]'.format(i) for i in args])) return eval(a) print(aaa("1
阅读全文
摘要:在写自动化过程中发现有不少场景需要用到缓存; 在研究测开框架的过程中,发现用到了线程锁、单例模式 一、对方法的参数锁(防止多线程破坏单例模式) 给方法创建一个__lock__ 对象,并赋值线程锁 def synchronized(func): func.__lock__ = threading.Lo
阅读全文
摘要:一、__doc__ """This is the module docstring""" class TestDoc: """类测试""" def demo(self): """方法注释""" pass if __name__ == '__main__': print(__doc__) print(
阅读全文
摘要:一、设置运行结果行数 1. File-->settings-->editor-->general-->appearance 2. 在show line numbers 前面打上√就可以。 二、模块控制先执行:pip freeze > requirements.txt再执行:pip install -
阅读全文
摘要:一、参数传递 #包裹位置传递 def func(*name): print( type(name), name) func(1,4,6) func(5,6,7,1,2,3) ''' 运行结果: <class 'tuple'> (1, 4, 6) <class 'tuple'> (5, 6, 7, 1
阅读全文
摘要:一、时间 import time print('获取当前时间<str类型>: ', time.strftime('%Y-%m-%d %H:%M:%S',time.localtime()) ) #获取当前时间<str类型>: 2019-03-14 21:53:28 print('获取当前时间戳<flo
阅读全文
摘要:一、filter(function, sequence): 对sequence中的item依次执行function(item),将执行结果为True的item组成一个List/String/Tuple(取决于sequence的类型)。 filter(function or None, sequenc
阅读全文

浙公网安备 33010602011771号