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

猜你喜欢

转载自www.cnblogs.com/ggzhangxiaochao/p/9104354.html