如何将字符串分配给 numpy 数组中的元素

How can I assign a strin to an element in numpy arrays

当我将字符串分配给数组时,它只选取第一个字符,而我需要整个字符串。我是不是用错方法了?

import numpy

i=0

def func(name,number,array,i):
    arry[i,0]=number
    array[i,1]=name
    print(array)

People= numpy.zeros([5,2],dtype=str)

func("qwe","123",People,i)

#this is the output    
 [['1' 'q']
 ['' '']
 ['' '']
 ['' '']
 ['' '']]
#this is the desired output
[['123' 'qwe']
 ['' '']
 ['' '']
 ['' '']
 ['' '']]

分配 people 数组来保存对象而不是字符串:

People= numpy.zeros([5,2], dtype=object)

print(func("qwe","123",People,i))
# [['123' 'qwe']
#  ['' '']
#  ['' '']
#  ['' '']
#  ['' '']]