DHCP query script not work.

Steven D'Aprano steve+comp.lang.python at pearwood.info
Thu Jun 19 09:14:34 EDT 2014


On Thu, 19 Jun 2014 05:56:57 -0700, 不坏阿峰 wrote:


> Traceback (most recent call last):
>   File "D:/Workspace/TestExcel/Test/test_DHCP.py", line 138, in <module>
>     offer = DHCPOffer(data, discoverPacket.transactionID)
>   File "D:/Workspace/TestExcel/Test/test_DHCP.py", line 82, in __init__
>     self.unpack()
>   File "D:/Workspace/TestExcel/Test/test_DHCP.py", line 95, in unpack
>     dnsNB = int(data[268] / 4)
> TypeError: unsupported operand type(s) for /: 'str' and 'int'


data[268] returns a string. You cannot divide a string by an int.

Perhaps you need to change the line to this?

dnsNB = int(data[268]) / 4



-- 
Steven D'Aprano



More information about the Python-list mailing list