python之模块base64
2024-08-30 11:49:40
# -*- coding: cp936 -*-
#python 27
#xiaodeng >>> help(base64) #用来作base64编码解码
FUNCTIONS #函数(功能)
•b16decode(s, casefold=False)
Decode a Base16 encoded string.
#解码
decode_string=base64.b16decode('7869616F64656E67')
print decode_string#xiaodeng
•b16encode(s)
Encode a string using Base16.
#编码
string=base64.b16encode('xiaodeng')
print string#7869616F64656E67
s is the string to encode. The encoded string is returned. •b32decode(s, casefold=False, map01=None)
Decode a Base32 encoded string.
#decode_string=base64.b32decode('PBUWC33EMVXGO===')
#print decode_string#xiaodeng
•b32encode(s)
Encode a string using Base32.
#string=base64.b32encode('xiaodeng')#PBUWC33EMVXGO===
s is the string to encode. The encoded string is returned. •b64decode(s, altchars=None)
Decode a Base64 encoded string.
#64位解码
#decode_string=base64.b64decode('eGlhb2Rlbmc=')##xiaodeng
s is the string to decode. Optional altchars must be a string of at least
length 2 (additional characters are ignored) which specifies the
alternative alphabet used instead of the '+' and '/' characters. The decoded string is returned. A TypeError is raised if s were
incorrectly padded or if there are non-alphabet characters present in the
string. •b64encode(s, altchars=None)
Encode a string using Base64.
#64位编码
#string=base64.b64encode('xiaodeng')#eGlhb2Rlbmc=
s is the string to encode. Optional altchars must be a string of at least
length 2 (additional characters are ignored) which specifies an
alternative alphabet for the '+' and '/' characters. This allows an
application to e.g. generate url or filesystem safe Base64 strings. The encoded string is returned.
•decode(input, output)
Decode a file.#解码一个文件
•encode(input, output)
Encode a file.#编码一个文件
•decodestring(s)#用来解码字符串
Decode a string.
#>>> base64.decodestring('xiaodeng')
#'\xc6&\xa8u\xe9\xe0'
•encodestring(s)#用来编码字符串
#>>> base64.encodestring('\xc6&\xa8u\xe9\xe0')
#'xiaodeng\n'
standard_b64decode(s)
Decode a string encoded with the standard Base64 alphabet. s is the string to decode. The decoded string is returned. A TypeError
is raised if the string is incorrectly padded or if there are non-alphabet
characters present in the string. standard_b64encode(s)
Encode a string using the standard Base64 alphabet. s is the string to encode. The encoded string is returned. urlsafe_b64decode(s)
Decode a string encoded with the standard Base64 alphabet. s is the string to decode. The decoded string is returned. A TypeError
is raised if the string is incorrectly padded or if there are non-alphabet
characters present in the string. The alphabet uses '-' instead of '+' and '_' instead of '/'. urlsafe_b64encode(s)
Encode a string using a url-safe Base64 alphabet. s is the string to encode. The encoded string is returned. The alphabet
uses '-' instead of '+' and '_' instead of '/'.
最新文章
- MICAPS数据文件格式
- js中,全局变量与直接添加在window属性的区别
- 关于实现Extjs动态加载类的方式实现
- 什么是P3O?
- Nivo Slider - 世界上最棒的 jQuery 图片轮播插件
- 关于Ajax中http协议
- flask笔记---url、变量规则
- JVM学习笔记(三)------内存管理和垃圾回收
- Python之路【第十三篇】:jQuery -暂无内容-待更新
- linux下的磁盘挂载
- JavaTCP和UDP套接字编程
- 强化学习(四)用蒙特卡罗法(MC)求解
- Ubuntu16.04下ZeroC ICE的安装与使用示例(Qt C++ 和 Java)
- Flink 报错 ";Could not find a suitable table factory for 'org.apache.flink.table.factories.StreamTableSourceFactory' in the classpath";
- [JS] ECMAScript 6 - Class : compare with c#
- C#中常用的单词
- Django models模型(1)
- JAVA框架 Spring 入门
- 洛谷P3375KMP字符串匹配
- ConcurrentLinkedQueue