首页 > 编程知识 正文

numpy 数据类型,python中nonetype指什么

时间:2023-05-03 17:14:54 阅读:19558 作者:2911

ijustwantedtoconfirmifthedefaultdatatypeforstringisunicodewhilecreatingandarray.icouldnotfindanyreferencewhichstatesthisclea

When dtype is specified:

import numpy as np

g=NP.Array(['a ',' b'jzdlb,['c ',' d'jzdlbjzdlb,dtype='S

g

Array([b'a ',b'b'jzdlb,

[b'c ',b'd'jzdlbjzdlb,

dtype偏好的吐司/pwithoutspecifyingthedtype :

g=NP.Array(['a ',' b'jzdlb,['c ',' d'jzdlbjzdlb

g

Array(['a ',' b'jzdlb,

['c ',' d'jzdlb,

dtype='

Also,whatdoestheliteralbindicatewhendtypeisspecified.asperthedocumentation,itindicatesboolwhichdoesn ' tseeeemtobetobethecasetethecasesesese

Can some one please clarify?

b ' . ' means it ' sa byte-stringandthedefaultdtypeforarraysofstringsdependsonthekindofstrings.unicodes (python 3字符串阵列) thedt ypes.youcanfindtheexplanationofdtypesinthenumpydocumentationhere

阵列协议类型字符串

thefirstcharacterspecifiesthekindofdataandtheremainingcharactersspecifythenumberofbytesperitem,except for Unicode, wereitisinterpretedasthenumberofcharacters.theitemsizemustcorrespondtoanexistingtype,oranerrorwillberaised.the suported

'? 布尔型

' b ' (已签名)字节

' b '未指定字节

“I”(签名) integer

' u' unsigned integer

' f '浮动点

' c' complex-floating point

' m' timedelta

' M' datetime

“O' (Python )对象

' s ',' a ' zero-terminated bytes (不建议) )。

' u ' unicode字符串

(' v '原始数据(void ) )。

howeverinyourfirstcaseyouactuallyforcednumpytoconvertittobytesbecauseyouspecifieddtype=' s '。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。