Converting a hex string to just hex in python

时间:2017-07-10 15:20:05

标签: python-2.7 hex ipv4

I have a program that takes an IPv4 address and converts it to hex. However, I am using a library that requires a variable using hex to be declared like this:

hexValue = 0x73FF0861

The method that I am using to convert the address to hex outputs a string, so whenever I assign the string hex value to a variable from the library, a value error is returned because the hex is a string. Is there any way in Python 2.7 to convert the IPv4 addresses to hex in a way that the library can use them?

1 个答案:

答案 0 :(得分:0)

您可以将十六进制字符串转换为十六进制,如下所示:

public static DisplayStyle Style = new DisplayStyle();