
Python
天意不可违.
千万利器莫过于你的信念
用博客记录一下自己学习的笔记。
展开
-
python模块:itsdangerous(生成临时身份令牌)
使用itsdangerous生成临时身份令牌 安装 pip install itsdangerous 使用 import itsdangerous salt='sdaf' #加盐 t = itsdangerous.TimedJSONWebSignatureSerializer(salt,expires_in=600)#过期时间600秒 info = { 'username': 'yangfan', 'user_id': 1 } # =========加密token============ res原创 2022-02-16 16:08:24 · 1603 阅读 · 0 评论 -
Python闭包、装饰器
闭包 闭包就是能够读取其他函数内部变量的函数。 def test1(k, b): def test1_1(x): print(k*x+b) return test1_1 t1 = test1(1, 2) t1(0) t1(1) t1(2) 闭包中修改数据 x = 300 def test1(): x = 200 def test2(): nonlocal x print("----1----x = {}".format(x)原创 2022-02-13 23:18:57 · 254 阅读 · 0 评论 -
python高级编程-网络编程、多任务
Python网络编程、多任务原创 2022-01-25 14:20:35 · 980 阅读 · 0 评论 -
Python中decode与encode的区别
decode是解码;encode是编码。 decode的作用是将其他编码的字符串转换成unicode编码,如str1.decode('gb2312'),表示将gb2312编码的字符串str1转换成unicode编码。 encode的作用是将unicode编码转换成其他编码的字符串,如str2.encode('gb2312'),表示将unicode编码的字符串str2转换成gb2312编码。 总得意思:想要将其他的编码转换成utf-8必须先将其解码成unicode然后重新编码成utf-8,它是以unicode原创 2021-01-12 15:33:11 · 3398 阅读 · 1 评论