报错解决:TypeError: Object type class 'str' cannot be passed to C code
此文首发于我的个人博客:报错解决 TypeError Object type class ‘str’ cannot be passed to C code — zhang0peter的个人博客
下午在使用Crypto
的时候报错如下:
Traceback (most recent call last):File "/usr/lib64/python3.6/multiprocessing/pool.py", line 119, in workerresult = (True, func(*args, **kwds))File "/usr/lib64/python3.6/multiprocessing/pool.py", line 44, in mapstarreturn list(map(*args))File "FastFinally.py", line 86, in generate2next(yield_32),next(yield_32)File "FastFinally.py", line 55, in AES_32_YIELDyield int(aes.encrypt(data).hex(),16)File "/usr/local/lib64/python3.6/site-packages/pycryptodome-3.9a0-py3.6-linux-x86_64.egg/Crypto/Cipher/_mode_ctr.py", line 201, in encryptc_uint8_ptr(plaintext),File "/usr/local/lib64/python3.6/site-packages/pycryptodome-3.9a0-py3.6-linux-x86_64.egg/Crypto/Util/_raw_api.py", line 235, in c_uint8_ptrraise TypeError("Object type %s cannot be passed to C code" % type(data))
TypeError: Object type <class 'str'> cannot be passed to C code
"""The above exception was the direct cause of the following exception:Traceback (most recent call last):File "FastFinally.py", line 97, in <module>pool.map(generate2,l)File "/usr/lib64/python3.6/multiprocessing/pool.py", line 266, in mapreturn self._map_async(func, iterable, mapstar, chunksize).get()File "/usr/lib64/python3.6/multiprocessing/pool.py", line 644, in getraise self._value
TypeError: Object type <class 'str'> cannot be passed to C code
我的代码如下:
from Crypto.Cipher import AES
from Crypto.Util import Counter
import os
key=os.urandom(16)
aes = AES.new(key, AES.MODE_CTR, counter=Counter.new(128))
data = "0" * 8
temp=aes.encrypt(data)
这部分代码在Windows上跑没问题,但是到Linux上跑就出错了。
把代码修改如下:
temp=aes.encrypt(data.encode('utf-8'))
只能说坑真多
报错解决:TypeError: Object type class 'str' cannot be passed to C code相关推荐
- python3运行报错:TypeError: Object of type ‘type‘ is not JSON serializable解决方法(详细)
python3运行报错:TypeError: Object of type 'type' is not JSON serializable解决方法(详细) 参考文章: (1)python3运行报错:T ...
- 【解决】控制台报错Uncaught TypeError: Object(...) is not a function at eval (vue-router.esm-bundler.js
打开http://localhost:8080/,控制台报错 Uncaught TypeError: Object(...) is not a functionat eval (vue-router. ...
- #报错解决#TypeError Failed to execute ‘readAsText‘ on ‘FileReader‘ parameter 1 is not of type ‘Blob‘
问题描述 在实现需求:批量下载的时候,返回的数据类型设置为blob $http({method: 'post',url: dataurl,data: bodyParam,headers: { 'Con ...
- python3运行报错:TypeError: Object of type 'type' is not JSON serializable解决方法
报这个错的原因是因为json.dumps函数发现字典里面有bytes类型的数据,无法编码.解决方法:在编码函数之前写一个编码类,只要检查到了是bytes类型的数据就把它转化成str类型. 这个编码类代 ...
- 返回 JSON 格式数据报错:TypeError: Object of type set is not JSON serializable
在做 flask 项目的时候需要返回一个 JSON 数据,运行的过程中却报错:TypeError: Object of type set is not JSON serializable 报错位置如下 ...
- 【报错管理】can only concatenate str (not float) to str
报错内容 TypeError: can only concatenate str (not "float") to str 代码 print("第"+(i+1) ...
- TypeError: ‘builtin_function_or_method‘ object is not subscriptable 报错解决方法
TypeError: 'builtin_function_or_method' object is not subscriptable 报错解决方法 参考文章: (1)TypeError: 'buil ...
- vue-cli3的项目 CDN链接报错解决 Uncaught TypeError: Cannot read property 'prototype' of undefined at Object.
Uncaught ReferenceError: iview is not defined 出现这个问题的原因是路径的问题 确保你的路径是正确的,或者是既全局引入了iview,又按需引入,会造成这样的 ...
- Python 使用pyinstaller打包exe文件报错: TypeError: an integer is required (got type bytes) 的解决方法
python打包成exe文件首先需要安装pyinstaller库,再进入到目标文件目录,输入命令行打包py文件,但出现报错:TypeError: an integer is required (got ...
最新文章
- mysql创建字段非空NOT NULL的好处
- solaris vi 方向键问题
- 使用TPU的注意事项
- java Class对象返回的都是指向同一个java堆地址上的Class引用
- 我对STL的一些看法(三)认识list容器
- git fork clone 区别_我的Git笔记
- APUE读书笔记-09进程关系(07)
- 如何通过输入域名直接访问项目地址
- YUY2(YUV) 与 RGB 格式图片的相互转换 以及 基于YUY2(YUV)的blending
- 《JQuery 能干点啥~》第8讲 XPath选择器
- 20150109--面向对象+对象传值-01
- 草料二维码 批量生成二维码
- 8位数控分频器的设计_数控分频器的VHDL设计
- 建材物资管理系统(软件定义)
- [微信小程序]搜索功能实现,搜索框样式
- 质量功能配置(QFD)矩阵
- [李景山php] web 安全资料篇
- 前端上班第一天-开发环境配置
- 网络工程——HCNA网络技术的简单配置
- JS高级程序设计(14)
热门文章
- 第十二课.统计推断的基本思想
- 微生物生态学相关期刊2022年实时影响因子
- 为什么你“越努力,越焦虑”?背后原因,99%的人都忽略了……
- Nature子刊:Knight组发布快速UniFrac算法
- 对不起,作为导师,我让您失望了!
- Maptree-层级结构数据展示的绝佳尝试
- Nature综述:真菌的多样性:真菌的高通量测序及鉴定
- 基因组重复序列注释-RepeatMasker安装和使用
- 微生物样本取样及微生物基因组DNA提取建议
- android switcher控件,Android ViewSwitcher 的功能与用法