yaschk
yaschk

Reputation: 330

How to get float values from string list

I have a column encodings in my sqllite database with datatype TEXT. For example, it is a str-type record: [-0.008732336573302746, 0.02287052385509014]. How to get float values from string list?

Upvotes: 0

Views: 53

Answers (2)

user10640506
user10640506

Reputation:

Use python’s built-in eval() to convert the string to python expression:

list_of_floats = eval(“[-0.34354989003, 1.4838348]”)

Upvotes: 0

Rafael
Rafael

Reputation: 7242

Just do:

my_list = eval("[-0.008732336573302746, 0.02287052385509014]")

Upvotes: 1

Related Questions