简体   繁体   中英

Python: Setting an element of a Numpy matrix

I am a pretty new to python. I have created an empty matrix

a = numpy.zeros(shape=(n,n))

Now I can access each element using

a.item(i,j)

How do I set an index (i,j)?

这是如何做:

a[i,j] = x

要么

a.itemset((i,j),x)

尝试这个

a[i,j]=5

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM