numpy.char.capitalize#
- char.capitalize(a)[source]#
返回
a
的副本,其中每个元素的第一个字符都已大写。逐元素调用
str.capitalize
。对于字节字符串,此方法是区域设置相关的。
- 参数:
- a类数组,其 dtype 为
StringDType
、bytes_
或str_
要大写的字符串输入数组。
- a类数组,其 dtype 为
- 返回:
- outndarray
输出数组的 dtype 为
StringDType
、bytes_
或str_
,具体取决于输入类型
另请参见
示例
>>> import numpy as np >>> c = np.array(['a1b2','1b2a','b2a1','2a1b'],'S4'); c array(['a1b2', '1b2a', 'b2a1', '2a1b'], dtype='|S4') >>> np.strings.capitalize(c) array(['A1b2', '1b2a', 'B2a1', '2a1b'], dtype='|S4')