如何在Pytorch中将字符串列表转换为字符串/字符张量?

numpy的相关示例:

import numpy as np

mylist = ["this","is","my","list"]

np.array([mylist])

返回值:

array([['this', 'is', 'my', 'list']], dtype='<U4')

但是,在pytorch中:

torch.tensor(mylist)

返回值:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-156-36722d81da09> in <module>
----> 1 torch.tensor(mylist)

ValueError: too many dimensions 'str'

张量是一个多维数组,所以我假设这是可能的pytorch。

Note: this post does not answer my question