numpy.strings.zfill#
- strings.zfill(a, width)[源代码]#
返回用零左填充的数字字符串。前导符号前缀(
+/-)通过在符号字符之后而不是之前插入填充来处理。- 参数:
- a类数组,具有
StringDType、bytes_或str_数据类型 - width类数组,具有任何整数 dtype
a 中用于左填充元素的字符串宽度。
- a类数组,具有
- 返回:
- outndarray
输出数组的
StringDType、bytes_或str_数据类型,取决于输入类型
另请参阅
示例
>>> import numpy as np >>> np.strings.zfill(['1', '-1', '+1'], 3) array(['001', '-01', '+01'], dtype='<U3')