数据的导入 从TXT文件中导入(x,y)坐标进数组并绘图 import numpy as np import pandas as pd import matplotlib.pyplot as plt #读取Txt中的数据 def readDataSets(filename): dataX1=[] dataX2=[] fr=open(filename) for line in fr.readlines(): # 对当前行去除首尾空格,并按空格分离 line_arr=line.strip().split() dataX1.append(float(line_arr[0])) dataX2.append(float(line_arr[1])) print(dataX1) print(dataX2) return dataX1,dataX2 if __name__=='__main__': # 导入数据集 作图 x,y=readDataSets('03train01.txt') plt.scatter(x,y,marker='o') x1,y1=readDataSets('03test01.txt') plt.scatter(x1,y1,marker='*') plt.show() 代耕……