Python3几个常见问题的处理方法
作者:iteye_6192 时间:2022-08-04 10:48:56
1. 编码问题:
遇到了几个字符串转换问题,总结如下:
# str to bytes
str.encode(s)
# bytes to str
bytes.decode(b)
判断编码方式可用chardet模块的chardet.detect(content)来协助。
2. char *有地址取内容:
strcontent = string_at(addr, -1)
3. 从动态链接库中获取函数并调用ctypes
from ctypes import *
dll = CDLL("YourAPP.dll")
dll.YourFunction()
4. 从dll中调用c程序,返回char*的情况处理
本来在32位下用string_at就可以解决,但是换成64位后内存访问出错。所以改用restype,终于解决。
#32位可行,64位出错:
result = dll.function()
result = string_at(result, -1)
print(result)
#后来改成用restype,32位/64位通用
dll.function.restype = c_char_p
result = dll.function()
print(result)
来源:https://blog.csdn.net/iteye_6192/article/details/82652781
标签:python,常见问题
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python读取键盘输入的2种方法
2023-03-14 22:08:37
详解python文件的操作和异常的处理
2021-06-07 04:05:37
![](https://img.aspxhome.com/file/2023/4/131264_0s.jpg)
vue学习教程之带你一步步详细解析vue-cli
2024-05-09 10:52:46
![](https://img.aspxhome.com/file/2023/3/126563_0s.jpg)
Python 使用folium绘制leaflet地图的实现方法
2023-06-11 05:58:36
![](https://img.aspxhome.com/file/2023/1/80421_0s.jpg)
python pandas读取csv后,获取列标签的方法
2022-01-14 22:35:30
SQL Server 2000中的触发器使用
2024-01-15 15:33:34
解密CSS Sprites:技巧、工具和教程
2011-01-11 19:38:00
![](https://img.aspxhome.com/file/UploadPic/20111/11/pokemon-29s.gif)
numpy系列之数组重塑的实现
2022-10-20 13:36:35
Python 基础知识之字符串处理
2023-04-22 05:47:55
python之PyAutoGui教你做个自动脚本计算器的方法
2022-01-08 15:24:55
![](https://img.aspxhome.com/file/2023/8/113118_0s.jpg)
sql 多条件组合查询,并根据指定类别找出所有最小子类别的SQL语句备忘
2024-01-20 09:01:50
Python图片检索之以图搜图
2021-08-11 12:08:23
![](https://img.aspxhome.com/file/2023/4/123514_0s.png)
浅谈Python在pycharm中的调试(debug)
2023-05-04 15:33:20
![](https://img.aspxhome.com/file/2023/1/125021_0s.jpg)
vue3.0使用mapState,mapGetters和mapActions的方式
2023-07-02 16:49:56
Vue2.0实现购物车功能
2023-07-02 16:54:22
![](https://img.aspxhome.com/file/2023/3/139813_0s.jpg)
ThinkPHP框架实现用户信息查询更新及删除功能示例
2024-06-07 15:34:11
![](https://img.aspxhome.com/file/2023/1/122481_0s.png)
SQL SERVER数据操作类代码
2012-07-11 16:16:12
python模块导入的细节详解
2021-01-09 19:18:08
![](https://img.aspxhome.com/file/2023/9/133529_0s.png)
Java 使用正则表达式对象实现正则的获取功能
2023-05-10 06:29:16
详解Python的Django框架中的中间件
2024-01-02 20:46:38