首页 > 解决方案 > python ctypes OSError:异常:访问冲突读取0x008B1000

问题描述

错误

Traceback (most recent call last):
  File "c:/Users/Administrator/Source/Repos/RSPluginKey/Debug/load.py", line 9, in <module>
    work.re("")#http been del
OSError: exception: access violation reading 0x008B1000

蟒蛇代码

from ctypes import *
import os

sdir = os.path.dirname(__file__)
work = CDLL(sdir + "\\RSPluginKey.dll")

print(work)

work.re("http://127.0.0.1")

cpp代码

#include "pch.h"
#include <iostream>
#include <string>
#include "requests.h"

extern "C" {//以此格式来添加引用函数
    __declspec(dllexport) void re(std::string http);
}

void re(std::string http) {
    using namespace std;
    using namespace requests;
    Response resp = Get(http);
    cout << resp.status << endl;
    cout << resp.GetText() << endl;
}

请求:https ://github.com/lxwAsm/requests

也许是请求或其他事情,我是 ctypes 的新用户,需要帮助!

怎么办?请

标签: pythonc++ctypes

解决方案


推荐阅读