import numpy as np 
 
x =  [1,2,3] 
a = np.asarray(x)  
print (a)
import numpy as np 
 
x =  (1,2,3) 
a = np.asarray(x)  
print (a)
import numpy as np 
 
x =  [(1,2,3),(4,5)] 
a = np.asarray(x)  
print (a)
import numpy as np 
 
x =  [1,2,3] 
a = np.asarray(x, dtype =  float)  
print (a)

 

 

import numpy as np 
 
s =  b'Hello World' 
a = np.frombuffer(s, dtype =  'S1')  
print (a)
import numpy as np
s =  'Hello World'
a = np.frombuffer(s, dtype =  'S1')
print (a)

import numpy as np 
 
# 使用 range 函数创建列表对象  
list=range(5)
it=iter(list)
 
# 使用迭代器创建 ndarray 
x=np.fromiter(it, dtype=float)
print(x)