# Encode or decode in django
1. Open views.py
import base64
import urllib
2. Use base64 in function for encode or decode
encode = base64.b64encode(str('2'))
print(encode)
output: Mg==
decode = base64.b64decode('Mg==')
url=urllib.unquote(decode).decode('utf8') -----optional
print(url)
output: 2
1. Open views.py
import base64
import urllib
2. Use base64 in function for encode or decode
encode = base64.b64encode(str('2'))
print(encode)
output: Mg==
decode = base64.b64decode('Mg==')
url=urllib.unquote(decode).decode('utf8') -----optional
print(url)
output: 2
No comments:
Post a Comment