python ctypes操作错误:异常:访问冲突读取0x008B1000

2024-03-28 20:34:10 发布

您现在位置:Python中文网/ 问答频道 /正文

错误

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

python代码

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的新uesr,需要帮助

怎么办


Tags: 代码importrehttpstringincludeosctypes