do_base64.py 340 B

1234567891011121314
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. import base64
  4. s = base64.b64encode('在Python中使用BASE 64编码'.encode('utf-8'))
  5. print(s)
  6. d = base64.b64decode(s).decode('utf-8')
  7. print(d)
  8. s = base64.urlsafe_b64encode('在Python中使用BASE 64编码'.encode('utf-8'))
  9. print(s)
  10. d = base64.urlsafe_b64decode(s).decode('utf-8')
  11. print(d)