-
-
Notifications
You must be signed in to change notification settings - Fork 11.4k
Open
Description
str to int or float
num_str = '10.6'
num_float = float(num_str) # Convert the string to a float first
num_int = int(num_float) # Then convert the float to an integer
print('num_int', int(num_str)) # 10
print('num_float', float(num_str)) # 10.6
num_int = int(num_float)
print('num_int', int(num_int)) # 10
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels