Say I got a string:
s = '''1 2 3
4 5 6
7 8 9
'''
I want to turn each line of string s into a list of floating-point value, that is:
l = [[1.0 2.0 3.0], [4.0 5.0 6.0], [7.0 8.0 9.0]]
How can I do this in one line?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Note
stripisn’t needed when there isn’t ‘loose’ spaces.Strip works as
trimeg. in php .