且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

(Python) TypeError:只有整数标量数组可以转换为标量索引

更新时间:2021-07-14 18:44:49

使用列表推导将 period 函数应用到 x 数组中的每个条目,就像这样 - >

Use list comprehension to apply period function to each entry in the x array like this -

y = np.array([period(i) for i in x])

另外,你需要同时初始化 demg -

Also, you need to initialize both dem and g -

dem = 0.0
g = 9.8