numpy.strings.zfill#

strings.zfill(a, width)[原始碼]#

傳回以零靠左填滿的數字字串。前導符號字首 (+/-) 的處理方式是在符號字元後而非之前插入填充。

參數:
a類陣列,具有 StringDTypebytes_str_ dtype
width類陣列,具有任何整數 dtype

字串寬度以靠左填滿 a 中的元素。

傳回值:
outndarray

輸出 StringDTypebytes_str_ dtype 的陣列,取決於輸入類型

另請參閱

str.zfill

範例

>>> import numpy as np
>>> np.strings.zfill(['1', '-1', '+1'], 3)
array(['001', '-01', '+01'], dtype='<U3')