10 examples of 'char to int in python' in Python

Every line of 'char to int 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
86def charToInt(char):
87 if char =="":
88 return 0
89 else:
90 return int(char)
352def ToChar(byte):
353 """Convert a byte to a character
354
355 This is useful because in Python 2 bytes is an alias for str, but in
356 Python 3 they are separate types. This function converts an ASCII value to
357 a value with the appropriate type in either case.
358
359 Args:
360 byte: A byte or str value
361 """
362 return chr(byte) if type(byte) != str else byte
98def int_to_chars(i):
99 parts = []
100 while i:
101 i, ic = divmod(i, 10)
102 parts.append(convert_int(ic))
103 parts = parts[::-1]
104 return [
105 '.'.join(parts[p][l] for p in range(len(parts))) for l in range(7)
106 ]
14def fourCharToInt(code):
15 return struct.unpack('>l', code)[0]
31def convertCodeToInt(code):
32 if not code:
33 return None
34 if " " in code:
35 return tuple([convertCodeToInt(i) for i in code.split(" ")])
36 return int(code, 16)
143def CChar(c):
144 return C_CHAR.get(c, c)
53def unichar(i):
54 return chr(i)
81def integer_from_Intel2(int_string):
82 # return first integer decoded from 2-byte-intel-format string
83 # jjk 04/25/96
84 return integer_from_Intel(int_string[:2])
30def c_to_f (c=0):
31 return int(c*9/5+32)
35def get_hex_for_char(char):
36 """
37 Returns the hex equivalent of the given character in the form 3C
38 """
39 return hex(ord(char))[2:]

Related snippets