array与List之间相互转化

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2018/5/28 16:05
# @Author  : zhang chao
# @File    : test.py
import matplotlib.pyplot as plt
import numpy as np
alist=[1,2,3,4,5]
print("List转为array:")
aArray=np.array(alist)
print(aArray)
print("array 转为List:")
toList=aArray.tolist()
print(toList)

D:\Download\python3\python3.exe "E:/A正在学习/python data dig/aTest/test.py"
List转为array:
[1 2 3 4 5]
array 转为List:
[1, 2, 3, 4, 5]

Process finished with exit code 0

 

posted on 2018-05-29 12:01  裸睡的猪  阅读(568)  评论(0编辑  收藏  举报