numpy.strings.zfill#
- strings.zfill(a, width)[原始碼]#
傳回以零靠左填滿的數字字串。前導符號字首 (
+
/-
) 的處理方式是在符號字元後而非之前插入填充。- 參數:
- a類陣列,具有
StringDType
、bytes_
或str_
dtype - width類陣列,具有任何整數 dtype
字串寬度以靠左填滿 a 中的元素。
- a類陣列,具有
- 傳回值:
- outndarray
輸出
StringDType
、bytes_
或str_
dtype 的陣列,取決於輸入類型
另請參閱
範例
>>> import numpy as np >>> np.strings.zfill(['1', '-1', '+1'], 3) array(['001', '-01', '+01'], dtype='<U3')