除了里面指定的3种(latin1, bytes , ASCII)还有哪些编码支持numpy
What other kinds of encoding support numpy besides of 3 specified inside (latin1, bytes , ASCII)
函数 numpy.genfromtxt 有一个选项可以选择指定的编码,在 npyio.py 代码中查看它似乎支持那些:
-latin1
-字节
-ASCII
它说不支持其他编码,所以这意味着还有另一种编码,最近我发现了另一种编码:latin,我相信它与latin1不完全相同,当我阅读行和extract information, but... 奇怪为什么不具体定义也能支持。我是否缺少另一种编码并且仍然适用于 numpy?
Edit1: numpy 版本是 1.20.1 在 python 3.8.8
np.npyio
中明确检查 -latin1 -bytes -ASCIC
的部分
是
def load():
即加载 np.save
个文件
encoding : str, optional
What encoding to use when reading **Python 2 strings**. Only useful when
loading Python 2 generated pickled files in Python 3, which includes
npy/npz files containing object arrays. Values other than 'latin1',
'ASCII', and 'bytes' are not allowed, as they can corrupt numerical
data. Default: 'ASCII'
(我的py2重点)
对于genfromtxt
,参数为:
encoding : str, optional
Encoding used to decode the inputfile. Does not apply when `fname` is
a file object. The special value 'bytes' enables backward compatibility
workarounds that ensure that you receive byte arrays when possible
and passes latin1 encoded strings to converters. Override this value to
receive unicode arrays and pass strings as input to converters. If set
to None the system default is used. The default value is 'bytes'.
并且代码只检查 bytes
。否则它只是将 encoding
参数传递给文件 open
。所以 Python/OS 文件系统处理的任何编码都可以。
这个encoding
参数比较新,我用的都是encoding=None
.
函数 numpy.genfromtxt 有一个选项可以选择指定的编码,在 npyio.py 代码中查看它似乎支持那些: -latin1 -字节 -ASCII
它说不支持其他编码,所以这意味着还有另一种编码,最近我发现了另一种编码:latin,我相信它与latin1不完全相同,当我阅读行和extract information, but... 奇怪为什么不具体定义也能支持。我是否缺少另一种编码并且仍然适用于 numpy?
Edit1: numpy 版本是 1.20.1 在 python 3.8.8
np.npyio
中明确检查 -latin1 -bytes -ASCIC
的部分
是
def load():
即加载 np.save
个文件
encoding : str, optional
What encoding to use when reading **Python 2 strings**. Only useful when
loading Python 2 generated pickled files in Python 3, which includes
npy/npz files containing object arrays. Values other than 'latin1',
'ASCII', and 'bytes' are not allowed, as they can corrupt numerical
data. Default: 'ASCII'
(我的py2重点)
对于genfromtxt
,参数为:
encoding : str, optional
Encoding used to decode the inputfile. Does not apply when `fname` is
a file object. The special value 'bytes' enables backward compatibility
workarounds that ensure that you receive byte arrays when possible
and passes latin1 encoded strings to converters. Override this value to
receive unicode arrays and pass strings as input to converters. If set
to None the system default is used. The default value is 'bytes'.
并且代码只检查 bytes
。否则它只是将 encoding
参数传递给文件 open
。所以 Python/OS 文件系统处理的任何编码都可以。
这个encoding
参数比较新,我用的都是encoding=None
.