Python训练营笔记 从0完成一个数据分析实战 Day11

天池龙珠计划 Python训练营

所记录的知识点

  1. ndarray -> str

ndarray -> str

ndarray(str类型元素) -> str
# ndarray -> str
print("np.array(['1','2','3','544','5'])\n",np.array(['1','2','3','544','5']),"\n")
print("type(np.array(['1','2','3','544','5']))\n",type(np.array(['1','2','3','544','5'])),"\n")

print("np.array(['1','2','3','544','5']).tolist()\n",np.array(['1','2','3','544','5']).tolist(),"\n")
print("type(np.array(['1','2','3','544','5']).tolist())\n",type(np.array(['1','2','3','544','5']).tolist()),"\n")

print("\" \".join(np.array(['1','2','3','544','5']).tolist())\n"," ".join(np.array(['1','2','3','544','5']).tolist()),"\n")
print("type(\" \".join(np.array(['1','2','3','544','5']).tolist()))\n",type(" ".join(np.array(['1','2','3','544','5']).tolist())),"\n")
np.array(['1','2','3','544','5'])
 ['1' '2' '3' '544' '5'] 

type(np.array(['1','2','3','544','5']))
 <class 'numpy.ndarray'> 

np.array(['1','2','3','544','5']).tolist()
 ['1', '2', '3', '544', '5'] 

type(np.array(['1','2','3','544','5']).tolist())
 <class 'list'> 

" ".join(np.array(['1','2','3','544','5']).tolist())
 1 2 3 544 5 

type(" ".join(np.array(['1','2','3','544','5']).tolist()))
 <class 'str'> 

ndarray(int类型元素) -> str
# ndarray -> str
print("np.array([1,2,3,544,5])\n",np.array([1,2,3,544,5]),"\n")
print("type(np.array([1,2,3,544,5]))\n",type(np.array([1,2,3,544,5])),"\n")

print("np.array([1,2,3,544,5]).tolist()\n",np.array([1,2,3,544,5]).tolist(),"\n")
print("type(np.array([1,2,3,544,5]).tolist())\n",type(np.array([1,2,3,544,5]).tolist()),"\n")

print("\" \".join(str(i) for i in np.array([1,2,3,544,5]).tolist())\n"," ".join(str(i) for i in np.array([1,2,3,544,5]).tolist()),"\n")
print("type(\" \".join(str(i) for i in np.array([1,2,3,544,5]).tolist()))\n",type(" ".join(str(i) for i in np.array([1,2,3,544,5]).tolist())),"\n")
np.array([1,2,3,544,5])
 [  1   2   3 544   5] 

type(np.array([1,2,3,544,5]))
 <class 'numpy.ndarray'> 

np.array([1,2,3,544,5]).tolist()
 [1, 2, 3, 544, 5] 

type(np.array([1,2,3,544,5]).tolist())
 <class 'list'> 

" ".join(str(i) for i in np.array([1,2,3,544,5]).tolist())
 1 2 3 544 5 

type(" ".join(str(i) for i in np.array([1,2,3,544,5]).tolist()))
 <class 'str'> 


欢迎各位同学一起来交流学习心得!

上一篇:Tensorflow 打印常量hello tensorflow


下一篇:Linux 下安装 jdk-7u75-linux-x64.gz,jdk1.7.0_75,jdk1.7步骤: