本帖最后由 阿奇_o 于 2021-5-7 09:40 编辑
第一印象:你们都学的什么奇怪的东西呀,dtype='S'
第二反应:从结果上看,应该是 字节存储 byte ,可为啥 dtype='S' ? 后面还显示为 |S1 ?
于是去查了一下,
StackOverflow有人回答:
The |S1 and |S2 strings are data type descriptors; the first means the array holds strings of length 1, the second of length 2.
The | pipe symbol is the byteorder flag; in this case there is no byte order flag needed, so it's set to |, meaning not applicable.
官方:不推荐!
'S', 'a' zero-terminated bytes (not recommended)
等等,这个 zero-terminated bytes 又是神马鬼??
再查.....
维基百科:
In computer programming, a null-terminated string is a character string stored as an array containing the characters and terminated with a null character (a character with a value of zero, called NUL in this article).
Alternative names are C string, which refers to the C programming language and ASCIIZ (although C can use encodings other than ASCII).
其他参考:A null-terminated byte string (NTBS) is a sequence of nonzero bytes followed by a byte with value zero (the terminating null character).
Each byte in a byte string encodes one character of some character set.
For example, the character array {'\x63','\x61','\x74','\0'} is an NTBS holding the string "cat" in ASCII encoding.
总结:这种存储格式,原来是 一串非零字节序列数组,如上面例子的'\x63','\x61','\x74' 这些是ASCII码,
然后 附带跟着一个0值位(故叫 null-terminated 或 zero-terminated),即上面例子的 '\0' 。
ps: 我为啥要找这一圈。。官方都不推荐的数据类型。。