How to get ip setting, dynamic ip or static ip?

kode4u kode4u at gmail.com
Wed Sep 27 13:16:01 EDT 2006


There are some errors in result:
>>> import win32com.client
>>> wmi=win32com.client.GetObject('winmgmts:')
>>> adapters=wmi.InstancesOf('Win32_NetworkAdapterConfiguration')
>>> for adapter in adapters:
...     print adapter.Properties_['Caption'],
adapter.Properties_['DhcpEnabled'], adapter.Properties_['IpAddress']
...
[00000001] Realtek RTL8139 Family PCI Fast Ethernet NIC True
(u'169.254.52.213',)
Traceback (most recent call last):
  File "<input>", line 2, in <module>
  File "C:\Python25\Lib\site-packages\win32com\client\dynamic.py", line
187, in __str__
    return str(self.__call__())
UnicodeEncodeError: 'ascii' codec can't encode characters in position
15-19: ordinal not in range(128)

How to deal with it?



Roger Upole wrote:
> "kode4u" <kode4u at gmail.com> wrote in message news:1158844868.766047.73270 at b28g2000cwb.googlegroups.com...
> > How to use python get my windows box's ip setting type? Dynamic ip, or
> > static ip?
> >
> > If it's static ip, what's the exact value?
> >
>
> You can use WMI to list properties of your network adapter(s):
> import win32com.client
> wmi=win32com.client.GetObject('winmgmts:')
> adapters=wmi.InstancesOf('Win32_NetworkAdapterConfiguration')
> for adapter in adapters:
>     print adapter.Properties_['Caption'], adapter.Properties_['DhcpEnabled'], adapter.Properties_['IpAddress']
>
>        Roger
>
>
>
>
> ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
> http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
> ---= East/West-Coast Server Farms - Total Privacy via Encryption =---




More information about the Python-list mailing list