Convert String to Int in Python
Conversion
String (Number) -> Int
For strings representing numbers, we can just use int
method in Python.
String (Text) -> Int
For strings representing characters, we need to convert each character to Unicode at first.
Then concatenate these unicoded string.
text = "Hello"
numbers_str = ""
for t in text:
numbers_str += str(ord(t))
print(int(decimal_str))
# 72101108108111