读书人

python调用 linux系统调用解决方案

发布时间: 2013-10-25 14:36:53 作者: rapoo

python调用 linux系统调用

为什么 我 百度 "python调用 linux系统调用" 什么都木有呢?
请问有没有 现成的包。可以用。

当然 我知道自己 python 调用 C的 .so..然后把每个要用的 系统调用封一下。就行。
有木有直接用 的 方法。。3Q。。
[解决办法]
ctypes模块。

教程:http://python.net/crew/theller/ctypes/tutorial.html
例子:

/tmp/ python
Python 2.7.5+ (default, Sep 17 2013, 15:31:50)
[GCC 4.8.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes
>>> libc = ctypes.CDLL("libc.so.6")
>>> libc.printf("Hello, %s\n", "world")
Hello, world
13

读书人网 >perl python

热点推荐