天池龙珠计划 Python训练营
所记录的知识点
- 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'>
欢迎各位同学一起来交流学习心得!