1, the read data, stored as an array numpy:
my_data = numpy.loadtxt('my_file.txt')
After numpy array is stored, the size can be my_data my_data.shape
view, with numpy.reshape()
modified dimensions.
2, the read data, stored as a list of list:
with open('my_file.txt', 'r') as f:
my_data = f.readlines() #txt中所有字符串读入data,得到的是一个list
# 对list中的数据做分隔和类型转换
for line in my_data:
line_data = line.split()
numbers_float = map(float, line_data) #转化为浮点数