【发布时间】:2018-03-06 09:50:12
【问题描述】:
我不知道如何将 Python 字符串转换为 numpy unicode 字符串
import numpy as np
py_str = "hello world"
#numpy_str = ?
【问题讨论】:
-
什么是 numpy unicode 字符串?您使用的是 Python 2 还是 3?
-
为什么不
np.array(py_str)?在 Py3 中,这将是未编码的。或np.unicode_(py_str)。通常,单个元素数组更有用,尽管它们共享许多相同的属性和方法。