10 examples of 'hexadecimal in python' in Python

Every line of 'hexadecimal in python' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
58def hex(x):
59 return int(x, 16)
348def input_hexadecimal_integer(self, token):
349 return int(token, 0x10)
26def _hex2dec(s):
27 return str(int(s,16))
18def handler(reobj):
19 intvalueStr = reobj.group(0)
20
21 r = hex(int(intvalueStr))
22 return r
26def is_hex(arg: str) -> bool:
27 try:
28 int(arg, 16)
29 return True
30 except ValueError:
31 return False
21def test_int_hexa_numbers():
22 assert list(lexer.lex("0x25")) == [
23 Token('NUMBER', "0x25"),
24 ]
26def hexify_int(value: int):
27 """
28
29 :param value:
30 :type value:
31 :return:
32 :rtype:
33 """
34 hexpiece = hex(value)[2:]
35 while len(hexpiece) < 6:
36 hexpiece = f'0{hexpiece}'
37 return hexpiece
39def is_hex_string(string):
40 """Check if the string is only composed of hex characters."""
41 pattern = re.compile(r"[A-Fa-f0-9]+")
42 if isinstance(string, six.binary_type):
43 string = str(string)
44 return pattern.match(string) is not None
51def get_hex_string(value):
52 v = '0x'
53 for c in value:
54 new_hex = hex(ord(c))[2:].upper()
55 if len(new_hex) < 2:
56 new_hex = '0' + new_hex
57 v += new_hex
58 return v
35def int_to_hex(i):
36 return format(i, 'x')

Related snippets