• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell
您的位置:首页 > 脚本语言 >python > python base64 decode incorrect padding错误解决方法

python base64 decode incorrect padding错误解决方法

作者:junjie 字体:[增加 减小] 来源:互联网

junjie 通过本文主要向大家介绍了incorrect padding,incorrect,incorrect什么意思,incorrect password,login incorrect等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

python的base64.decodestring方法做base64解码时报错:
Traceback (most recent call last):
  File "/export/www/outofmemory.cn/controllers/user.py", line 136, in decryptPassword
    encryptPwd = base64.b64decode(encryptPwd)
  File "/usr/lib/python2.7/base64.py", line 76, in b64decode
    raise TypeError(msg)
TypeError: Incorrect padding
</div>
这也算是python的一个坑吧,解决此问题的方法很简单,对base64解码的string补齐等号就可以了,如下代码:
        def decode_base64(data):
            """Decode base64, padding being optional.

            :param data: Base64 data as an ASCII byte string
            :returns: The decoded byte string.

            """
            missing_padding = 4 - len(data) % 4
            if missing_padding:
                data += b'='* missing_padding
            return base64.decodestring(data)
</div>

</div>

您可能想查找下面的文章:

  • python base64 decode incorrect padding错误解决方法
  • python base64 decode incorrect padding错误解决方法

相关文章

  • Python中删除文件的程序代码
  • python实现二维码扫码自动登录淘宝
  • Python Web框架Pylons中使用MongoDB的例子
  • 在Python中利用Pandas库处理大数据的简单介绍
  • python中argparse模块用法实例详解
  • 浅谈Python中的闭包
  • python实现类的静态变量用法实例
  • 使用Python绘制图表大全总结
  • 在Python中使用pngquant压缩png图片的教程
  • python使用chardet判断字符串编码的方法

文章分类

  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell

最近更新的内容

    • Python中super关键字用法实例分析
    • 在Python中使用M2Crypto模块实现AES加密的教程
    • Python 冒泡,选择,插入排序使用实例
    • Python自定义函数的创建、调用和函数的参数详解
    • Python 调用VC++的动态链接库(DLL)
    • 使用Python写CUDA程序的方法
    • python+mysql实现简单的web程序
    • Python fileinput模块使用实例
    • Python简单操作sqlite3的方法示例
    • Python中用于转换字母为小写的lower()方法使用简介

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有