python之模块base64
- # -*- 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 '/'.
python之模块base64的更多相关文章
- Python常用模块--base64
作用:对一些保密性不强的信息进行加密,变为人类不能直接理解的字符串,但是可以反向解密,是一种‘防君子,不防小人’的措施. 例如:在一些项目中,接口的报文是通过base64加密传输的,所以在进行接口自动 ...
- python进阶06 常用问题库(2)datetime模块 base64
python进阶06 常用问题库(2)datetime模块 base64 一.datetime模块(时间) 1.datetime.time() t=datetime.time(20,43,30,1) ...
- python基础之内建模块base64
一.Base64概念 什么是Base64? 按照RFC2045的定义,Base64被定义为:Base64内容传送编码被设计用来把任意序列的8位字节描述为一种不易被人直接识别的形式.(The Base6 ...
- python 各模块
01 关于本书 02 代码约定 03 关于例子 04 如何联系我们 1 核心模块 11 介绍 111 内建函数和异常 112 操作系统接口模块 113 类型支持模块 114 正则表达式 115 语言支 ...
- python hashlib模块 md5加密 sha256加密 sha1加密 sha512加密 sha384加密 MD5加盐
python hashlib模块 hashlib hashlib主要提供字符加密功能,将md5和sha模块整合到了一起,支持md5,sha1, sha224, sha256, sha384, ...
- Python常用模块——目录
Python常用模块学习 Python模块和包 Python常用模块time & datetime &random 模块 Python常用模块os & sys & sh ...
- python email模块
python email模块 官方文档 email模块 电子邮件包是一个用于管理电子邮件消息的库.它的特殊设计不用于向SMTP (RFC 2821).NNTP或其他服务器发送任何电子邮件消息;这些是模 ...
- Python Fabric模块详解
Python Fabric模块详解 什么是Fabric? 简单介绍一下: Fabric是一个Python的库和命令行工具,用来提高基于SSH的应用部署和系统管理效率. 再具体点介绍一下,Fabri ...
- Python标准模块--threading
1 模块简介 threading模块在Python1.5.2中首次引入,是低级thread模块的一个增强版.threading模块让线程使用起来更加容易,允许程序同一时间运行多个操作. 不过请注意,P ...
随机推荐
- 要恢复页面吗?Chrome未正确关闭
谷歌chrome浏览器每次打开提示"要恢复页面吗"怎么办? 谷歌chrome浏览器每次打开提示"要恢复页面吗"怎么办? 如下图所示: 每次打开启动谷歌chrom ...
- 最近遇到了 timer1sec 定时调用的函数,出现了 时间久了,就不是每秒一次了,可能会慢的情况。如何解决呢?
我想可以在timer1sec 调用四个线程,让四个线程来执行 具体代码,而不是在timer1sec一个线程 直接执行.这样,每个线程 不超过4s,那么没秒都会被调用到. 需要使用到的技术是 semap ...
- 里氏替换原则(Liskov Substitution Principle,LSP)
肯定有不少人跟我刚看到这项原则的时候一样,对这个原则的名字充满疑惑.其实原因就是这项原则最早是在1988年,由麻省理工学院的一位姓里的女士(Barbara Liskov)提出来的. 定义1:如果对每一 ...
- Sql Server简单加密与解密 【转】
前言: 在SQL Server 2005和SQL Server 2008之前.如果希望加密敏感数据,如财务信息.工资或身份证号,必须借助外部应用程序或算法.SQL Server 2005引入内建数据加 ...
- Log Shipping搭建
1. 概述 SQL Server 使用日志传送,您可以自动将“主服务器”实例上“主数据库”内的事务日志备份发送到单独“辅助服务器”实例上的一个或多个“辅助数据库”.事务日志备份分别应用于每个辅助 ...
- Swift3.0:NSURLConnection的使用
一.介绍 应用中也不必不可少的会使用网络通信,增强客户端和服务器的交互,可以使用NSURLConnection实现http通信. NSURLConnection提供了异步请求和同步请求两种请求方式.同 ...
- 如何让Domain里的其他系统通过DC来进行外网的DNS解析
搭建一个测试环境, 一般会建立一个DC, 然后再建立许多虚机加入到这个新DC的domain. 我们有个DNS服务器的地址, 哪台虚机要上外网, 就把这个DNS地址填到这台虚机的DNS server a ...
- JavaScript Math和Number对象研究
1. Math 对象 1.1 介绍 Math 对象,是数学对象,提供对数据的数学计算,如:获取绝对值.向上取整等.无构造函数,无法被初始化,只提供静态属性和方法. 1.2 构造函数 无 : ...
- JQuery实现可编辑的表格
点击表格后可直接编辑,回车或鼠标点击页面其他地方后编辑生效,按Esc可取消编辑 第一种单击表格可以编辑的方法 //相当于在页面中的 body标签加上onload事件$(function() { ...
- 大数据开发实战:Hive优化实战2-大表join小表优化
4.大表join小表优化 和join相关的优化主要分为mapjoin可以解决的优化(即大表join小表)和mapjoin无法解决的优化(即大表join大表),前者相对容易解决,后者较难,比较麻烦. 首 ...