功能一:不用postman发起post请求测试接口
import requests
res = requests.post('http://localhost:8000/mysite/').text
print(res)
功能二:md5加密算法
import hashlib
def make_password(mypass):
mypass = hashlib.md5()
mypass.update('456'.encode('utf-8'))
return mypass.hexdigest()
print(make_password(123456))
功能三: redis存入和获取的使用
import redis
r = redis.Redis('localhost')
r.set('mykey','test')
mycode = r.get('mykey')
mycode = mycode.decode('utf-8')
print(mycode)
功能四:jwt加密
import jwt
encode_jwt = jwt.encode({'uid':'11'},'123',algorithm='HS256')
encode_str = str(encode_jwt,'utf-8')
de_code = jwt.decode('eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1aWQiOiIxMSJ9.8wUhXvOPt7PqtWgOaXSnTcAIDT6tf94HbTexMpyVhHs','123',algorithms=['HS256'])
print(de_code)