【问题标题】:What is the meaning of vertical bar in array dtype ('|S58')数组dtype('|S58')中的竖线是什么意思
【发布时间】:2017-07-05 00:48:39
【问题描述】:

我尝试做时出错

np.savetxt(f, te_filename)

返回错误

% (str(X.dtype), format))

TypeError:数组 dtype ('|S58') 和格式说明符 ('%.18e') 不匹配

我检查了文档页面,

https://docs.scipy.org/doc/numpy-1.10.0/reference/arrays.dtypes.html

好像S代表字符串,58是长度,那么竖线是什么意思呢?

【问题讨论】:

标签: python numpy


【解决方案1】:

这是一个byte order specifier,指定“字节顺序不适用”。

  • '=':原生
  • '
  • '>': 大端序
  • '|':不适用

【讨论】:

  • 感谢您的回答。您介意进一步解释为什么在这种情况下不适用吗?不都是大端还是小端?
  • @LanceRuoZhang:big-endian 或 little-endian 1 字节字符之间没有区别。
  • S 是一个字节串(py2 中的常规字符串),每个字符一个字节。 endian 适用于数字。
  • 一个 unicode 字符串的 dtype 如下:array('one', dtype='<U3')
猜你喜欢
  • 2012-04-27
  • 1970-01-01
  • 2011-06-26
  • 2015-09-29
  • 1970-01-01
  • 1970-01-01
  • 2015-07-04
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多