Python : Lấy tên card mạng trên máy tính - Windows 7

Hi all,

Mình đang học về Python, script sau đây mục đích là lấy thông tin máy tính. Bao gồm : hostname, IP Address và Domain name. Nhưng còn interface network name thì mình không lấy đc, kết quả là các chuỗi ký tự như bên dưới.
Có bạn nào biết về library netifaces thì giúp mình chỗ này với.

import socket
import netifaces
import string

def print_machine_info():
host_name = socket.gethostname()
ip_address = socket.gethostbyname(host_name)
full_FQDN_info = socket.getfqdn()
location = full_FQDN_info.find(’.’)
search_Hostname = full_FQDN_info.find(host_name)
print "Host name: %s " % host_name
print "IP Address: %s " % ip_address
print "FQDN of this computer: %s " % full_FQDN_info
print “Domain name of this computer: %s” % full_FQDN_info[location+1:]

def get_network_interface():
result = netifaces.interfaces()
gateway = netifaces.gateways()
print result
print gateway[‘default’][netifaces.AF_INET]

if name == ‘main’:
print_machine_info()
get_network_interface()

Kết quả như bên dưới :

Host name: AAAAAA
IP Address: 192.168.1.4
FQDN of this computer: AAAAAA .domain.com
Domain name of this computer: domain.com
[’{ECF07DD5-27DA-4B1B-A943-C555607CA113}’, ‘{F8CAEFE8-B0FD-4FB5-B36A-360CF8F7A56F}’, ‘{DA12A915-E7DF-4E58-A253-D0FF5EB2E735}’, ‘{E14F3D30-E198-4DFB-B0AA-57C7094BA700}’, ‘{846EE342-7039-11DE-9D20-806E6F6E6963}’, ‘{226833B8-5323-482F-91B0-03B0D0001A87}’, ‘{002B4FBC-6974-4C55-9E0B-7866E810BA83}’, ‘{FC0EF0EA-399F-4FFE-9B7A-08E077ED958A}’, ‘{0B227AAE-53DF-46A9-A16A-A387C1FF951F}’]
> (‘192.168.1.1’, u’{F8CAEFE8-B0FD-4FB5-B36A-360CF8F7A56F}’)

Mình muốn hỏi cách encode cái đoạn bôi đen ở trên thành tên của card mạng trên máy tính như “Local Area Connection” hoặc “Local Area Connection 2” thì làm cách nào.

83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?