如何调用整数的np.zero?

2024-04-26 09:19:44 发布

您现在位置:Python中文网/ 问答频道 /正文

Musica = np.zeros((row*120,3))

for k in range(21, 90):
    for i in range(row):
        for j in range(Max[k], Min[k]):
            Musica[i*120 + j,:] = 0,i,j
            if np.all(data[i*col + j,:]==(255.000,0.000,0.000,i,j)):
                Music[i*120 + j,:] = 1,i,j

Max[k]Min[k]是属于数学整数组的数字,但是我从python得到这个消息

"TypeError: range() integer end argument expected, got numpy.float64."

如何调用整数类型的np.zeros

现在我正试着使用休耕代码:

Musica = np.zeros((row*120,3))

for k in range(21, 90):
    for i in range(row):
        Max = int(Max[k])
        Min = int(Min[k])
        for j in range(Max, Min):
            Musica[i*120 + j,:] = 0,i,j
            if np.all(data[i*col + j,:]==(255.000,0.000,0.000,i,j)):
                Musica[i*120 + j,:] = 1,i,j

我收到的错误信息是:

Traceback (most recent call last):

  File "<ipython-input-115-4aef2441146c>", line 1, in <module>
    runfile('C:/Users/Arthur_USP/Desktop/Informação/Nova abordagem/untitled0.py', wdir='C:/Users/Arthur_USP/Desktop/Informação/Nova abordagem')

  File "C:\Users\Arthur_USP\Anaconda2\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 699, in runfile
    execfile(filename, namespace)

  File "C:\Users\Arthur_USP\Anaconda2\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 74, in execfile
    exec(compile(scripttext, filename, 'exec'), glob, loc)

  File "C:/Users/Arthur_USP/Desktop/Informação/Nova abordagem/untitled0.py", line 181, in <module>

TypeError: 'int' object has no attribute '__getitem__'

其中第181行是“Max=int(Max[k])”


Tags: inpyfornplinerangeminusers