使用python中的ctypes模块可以很方便的调用windows的dll(也包括linux下的so等文件)

引入ctypes库 有两种方法

from ctypes import *
import ctypes

加载DLL

stdcall调用约定:两种加载方式

Objdll = ctypes.windll.LoadLibrary("dllpath")
Objdll = ctypes.WinDLL("dll")

cdecl调用约定:也有两种加载方式

Objdll = ctypes.cdll.LoadLibrary("dllpath")
Objdll = ctypes.CDLL("dll")

引入ctypes库的方法不同,对应不同的加载DLL方式

第一种:

from ctypes import *

Objdll = ctypes.WinDLL("dll")
#或者
Objdll = ctypes.CDLL("dll")

第二种:

import ctypes

Objdll = ctypes.windll.LoadLibrary("dllpath")
#或者
Objdll = ctypes.cdll.LoadLibrary("dllpath")

Python 报错:NameError: name 'ctypes' is not defined的更多相关文章

  1. 报错NameError: name ‘null’ is not defined的解决方法

    报错NameError: name 'null' is not defined的解决方法 eval()介绍 eval()函数十分强大,官方demo解释为:将字符串str当成有效的表达式来求值并返回计算 ...

  2. Python,报错NameError: name 'math' is not defined

    1 #-*- coding : utf-8 -*- 2 import math 3 4 def move(x, y, step, angle=0): 5 nx = x + step * math.co ...

  3. py+selenium 报错NameError: name 'NoSuchElementException' is not defined【已解决】

     报错:NameError: name 'NoSuchElementException' is not defined  如图 解决方法: 头部加一句:from selenium.common.exc ...

  4. python2执行程序报错:NameError: name 'y' is not defined

    然后运行一直报错 这个错误,是由于版本不同造成的语法错误,在python3中,输入可以使用input,但如果你的版本是python2,那么此时input就得改成raw_input,否则你输入数据会被当 ...

  5. Python2.7错误处理FileNotFoundError报错NameError: name 'FileNotFoundError' is not defined

    错误信息如下: 原因是FileNotFoundError是python3.0中的写法,而Python2.7中应写为IOError.

  6. [报错]-NameError: name 'NAN' is not defined

    部分数据输出为NaN,处理这部分异常数据使用isnan()函数 from math import isnan isnan(z) 参考: https://www.cnblogs.com/itdyb/p/ ...

  7. Python报错总结丶自定义报错

    Python报错总结: 常见异常 1,NameError: name 'a' is not defined:未定义函数名             2,IndentationError: uninden ...

  8. Python报错module 'scipy.misc' has no attribute 'xxx'

    Python报错module 'scipy.misc' has no attribute 'imresize' 解决办法: 安装Pillow包,命令如下: pip install Pillow 然后重 ...

  9. selenium python 报错“ unable to find binary in default location”

    selenium python 报错如下: raise exception_class(message, screen, stacktrace)selenium.common.exceptions.W ...

  10. 解决Python报错:local variable 'xxx' referenced before assignment(引)

    解决Python报错:local variable 'xxx' referenced before assignment(引) 解决Python报错:local variable 'xxx' refe ...

随机推荐

  1. 案例 (一)如何把python项目部署到linux服务器上

      一.背景 用Python写了个脚本,需要部署到Linux环境的服务器上,由于服务器linux系统(centos,redhat等)自带的是python2,现在的python萌新都是从python3开 ...

  2. Reflux之Store

    Reflux中的Store既是一个listener(既有对action的监听,又有对store的监听)同时又是一个publisher. 一.监听单个action const Reflux = requ ...

  3. layui菜单点击刷新,自适应

    最近在项目上用layui框架后台iframe版,遇到的一些问题分享: 1.项目的左侧菜单点击对应的子菜单能自动刷新问题. 2.除了在左侧有菜单,还需要在右侧需要一个菜单(跳转到新页面),并且能够伸缩自 ...

  4. 第一篇:百度AI注册使用

    百度AI (https://ai.baidu.com/)点击右上角<控制台>进行登录 内容审核: 操作文档:

  5. Alink漫谈(四) : 模型的来龙去脉

    Alink漫谈(四) : 模型的来龙去脉 目录 Alink漫谈(四) : 模型的来龙去脉 0x00 摘要 0x01 模型 1.1 模型包含内容 1.2 Alink的模型文件 0x02 流程图 0x03 ...

  6. vue生命周期函数2

    转载:http://blog.csdn.net/qq_15766181/article/details/73549933 钩子就好像是把人的出生到死亡分成一个个阶段,你肯定是在出生阶段起名字,而不会在 ...

  7. dsPIC单片机的CAN引脚设置

    用单片机的引脚复用 查询芯片数据手册C1RX的寄存器为RPINR26.C1RXR=(设置为需要用到的引脚) 引脚设置为输入(C1RX),TRIS=1: C1TX需要用的引脚为RPn41,查询数据手册R ...

  8. NodeJS——模块全局安装路径配置以及关于supervisor的问题解释

    下载安装NodeJS后,在自己选择的路径下会有如下的文件: 默认情况下NodeJS安装会同时安装npm(模块管理器:用于管理用户require的模块,有全局和本地两种). 注:全局:执行npm  in ...

  9. PAT 1033 To Fill or Not to Fill (25分) 贪心思想

    题目 With highways available, driving a car from Hangzhou to any other city is easy. But since the tan ...

  10. ## H5 canvas画图白板踩坑

    最近接手了一个小型的H5,最主要的功能大概就是拍照上传和canvas画板了. 主要是记录一下自己菜到像傻子一样的技术. 1.canvas画板隔空打牛!画布越往上部分错位距离越小,越往下距离越大. 2. ...