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