How to create a numpy array of arbitrary length strings?

后端 未结 2 1016
死守一世寂寞
死守一世寂寞 2020-11-27 15:53

I\'m a complete rookie to Python, but it seems like a given string is able to be (effectively) arbitrary length. i.e. you can take a string str and keeping add

2条回答
  •  执念已碎
    2020-11-27 16:24

    You could use the object data type:

    >>> import numpy
    >>> s = numpy.array(['a', 'b', 'dude'], dtype='object')
    >>> s[0] += 'bcdef'
    >>> s
    array([abcdef, b, dude], dtype=object)
    

提交回复
热议问题