小编ato*_*ozh的帖子

list(numpy_array)和numpy_array.tolist()之间的区别

是什么应用之间的区别list()一对numpy阵列与调用tolist()

我正在检查两个输出的类型,它们都显示我得到的结果是list,但是,输出看起来并不完全相同.是因为那list()不是一个numpy特定的方法(即可以应用于任何序列)并且tolist() numpy特定的,并且只是在这种情况下它们返回相同的东西?

输入:

points = numpy.random.random((5,2))
print "Points type: " + str(type(points))
Run Code Online (Sandbox Code Playgroud)

输出:

Points type: <type 'numpy.ndarray'>
Run Code Online (Sandbox Code Playgroud)

输入:

points_list = list(points)
print points_list
print "Points_list type: " + str(type(points_list))
Run Code Online (Sandbox Code Playgroud)

输出:

[array([ 0.15920058,  0.60861985]), array([ 0.77414769,  0.15181626]), array([ 0.99826806,  0.96183059]), array([ 0.61830768,  0.20023207]), array([ 0.28422605,  0.94669097])]
Points_list type: 'type 'list''
Run Code Online (Sandbox Code Playgroud)

输入:

points_list_alt = points.tolist()
print points_list_alt
print "Points_list_alt type: " + str(type(points_list_alt))
Run Code Online (Sandbox Code Playgroud)

输出:

[[0.15920057939342847, 0.6086198537462152], …
Run Code Online (Sandbox Code Playgroud)

python arrays numpy list

6
推荐指数
1
解决办法
2559
查看次数

Java数组[i] ++ vs ++ array [i]

我有一系列的整数:

private int array[];
Run Code Online (Sandbox Code Playgroud)

如果我还有一个名为add的方法,那么下面的区别是什么:

public void add(int value) {
   array[value]++; VS ++array[value];
}
Run Code Online (Sandbox Code Playgroud)

ps另外注意,int array []和int []数组有什么区别?谢谢

java arrays indexing

2
推荐指数
1
解决办法
5895
查看次数

标签 统计

arrays ×2

indexing ×1

java ×1

list ×1

numpy ×1

python ×1