当前位置:主页 > 软件编程 > Python代码 >
时间:2021-04-28 08:08:09 | 栏目:Python代码 | 点击:次
如果直接用python的一个list除以一个数,会报错:
a = [1.0, 1.0, 1.0] c = a/3 print(c)
TypeError: unsupported operand type(s) for /: 'list' and 'int'
使用Numpy可以轻松做到:
import numpy as np a = np.array([1,1,1]) c = a/3 print(c)