第二,为了能够分开使用这个函数返回的group和labels 。
我们可以这么做使用 fun()[1] // 下标从0开始,来调取返回值
代码如下 :
www= createDataSet() print("group的值为") print(www[0]) print("lables的值为") print(www[1]) 12345 最后结果显示如下: group的值为 [[ 1. 1.1] [ 1. 1. ] [ 0. 0. ] [ 0. 0.1]] lables的值为 ['A', 'A', 'B', 'B'] 1234567 <link href="https://csdnimg.cn/release/phoenix/mdeditor/markdown_views-e9f16cbbc2.css" rel="stylesheet"> </div>