How to Convert a Python String to an Int and an Int to a String?

Rate this post

String → Integer:

s = "42"
i = int(s)
# i == 42

Integer → String:

i = 42
s = str(i)
# s == "42"

Leave a Comment