Answer the question
In order to leave comments, you need to log in
How to convert str to list?
Tell me, I’m deriving a string from the database (mysql) and I don’t know how to convert it to the desired form
. As an example, this code:
mystr = "-0.09634063, 0.12095481, -0.00436332, -0.07643753, 0.0080383, 0.01902981"
print([mystr])
результат выполнения такой:
>> ['-0.09634063, 0.12095481, -0.00436332, -0.07643753, 0.0080383, 0.01902981']
mystr = [-0.09634063, 0.12095481, -0.00436332, -0.07643753, 0.0080383, 0.01902981]
print([mystr])
>>
Answer the question
In order to leave comments, you need to log in
Managed to solve (convert) in this way: np.fromstring(mystr , dtype=float, sep=', ')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question