新人求教
RT想用python获取当前主机上面所有网卡信息的列表如何做
不要检索ifconfig或者/dev/net里面的信息
我想要一个类似C里面ioctl的调用 来获取硬件信息 fcntl — The fcntl and ioctl system calls
This module performs file control and I/O control on file descriptors. It is an interface to the fcntl() and ioctl() Unix routines.
All functions in this module take a file descriptor fd as their first argument. This can be an integer file descriptor, such as returned by sys.stdin.fileno(), or a io.IOBase object, such as sys.stdin itself, which provides a fileno() that returns a genuine file descriptor. 回复 2# timespace
我知道不过有些细节不十分清楚
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
如果要获取的是网卡信息参数改怎么写呢?
fcntl.ioctl(s.fileno(),?? )
https://docs.python.org/2/library/fcntl.html
我只找到了获取终端的例子参数如果模仿C的用法填写(比如一些宏定义的名字)根本不行 用module行不?
https://pypi.python.org/pypi/netifaces 不知道这样做有什么好处呢?
"重复发明轮子", 除了浪费自己的时间之外, 还有其它的意义么? 3楼楼长 +1,能用module是极好的。ioctl很依赖所在OS,首先应该会用C的ioctl,然后再用Python的fcntl.ioctl。宏就是几个数字,没什么特别的,如果fcntl没定义,就到系统头文件找宏的数值。 回复 4# r2007
thank you very much!!!
页:
[1]