Daftar string Python untuk mengambang
[float(i) for i in lst]
Cruel Crane
[float(i) for i in lst]
# Basic syntax:
[str(x) for x in list_of_floats]
# Example usage:
list_of_floats = [1.2, 1.7, 3.141592654]
[str(x) for x in list_of_floats]
--> ['1.2', '1.7', '3.141592654']
import numpy as np
test = "5,4,3,2";
lst = test.split(",");#lst is list of strings
a = np.array(lst,dtype=np.float32) #convert to numpy array of floats