I want to change the string from Python to float or int

Asked 2 years ago, Updated 2 years ago, 100 views

From Python "30.33333" to float 30.3333 "30" like int 30 What should I do to change my brother?

string python parsing floating-point integer

2022-09-22 22:36

1 Answers

float("30.3333") int("30") You can use it together. Python is easy

If you want to make an exception together, write as follows

def stringToInt(num):
    try:
        int(num)
    except:
        #Exception Processing


2022-09-22 22:36

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.