How to get Network Interface Card names in Python?

后端 未结 9 1834
灰色年华
灰色年华 2020-12-06 09:36

I am totally new to python programming so please be patient with me.

Is there anyway to get the names of the NIC cards in the machine etc. eth0, lo? If so how do you

9条回答
  •  没有蜡笔的小新
    2020-12-06 10:01

    Like David Breuer say, you can just list the directory "/ sys / class / net" on Linux. (It works on Fedora at least). If you need detailled information about some interface you can navigate on the intefaces's directories for more.

    def getAllInterfaces():
        return os.listdir('/sys/class/net/')
    

提交回复
热议问题