10 examples of 'convert int to hex python' in Python

Every line of 'convert int to hex 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
35def int_to_hex(i):
36 return format(i, 'x')
58def hex(x):
59 return int(x, 16)
30def hex2dec(hex):
31 """ Convert and hex value in a decimal number
32 """
33 return int(hex, 16)
38def hex_to_long(hex_string):
39 return int(hex_string, 16)
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
25def hex2bin(hexstr):
26 """Convert a hexdecimal string to binary string, with zero fillings. """
27 num_of_bits = len(hexstr) * 4
28 binstr = bin(int(hexstr, 16))[2:].zfill(int(num_of_bits))
29 return binstr
13def bin2hex(s):
14 return '%0*X' % ((len(s) + 3) // 4, int(s, 2))
26def _hex2dec(s):
27 return str(int(s,16))
7def hex_to_tuple(t):
8 return (
9 int(t[0:2], base = 16),
10 int(t[2:4], base = 16),
11 int(t[4:6], base = 16)
12 )
45def to_hex(number):
46 if number is not None:
47 h = hex(number)
48 if h.endswith('L'):
49 h = h[:-1]
50 else:
51 h = None
52 return h

Related snippets