Numpy 的 join(~)
方法返回一个 Numpy 字符串数组,其中第一个数组中的字符串插入到第二个数组的字符串的每两个相邻字符之间。检查示例以进行说明。
参数
1. sep
| array-like
用于分隔 seq
的字符串。
2. seq
| array-like
要分隔的字符串序列。
返回值
一个 Numpy 字符串数组。
例子
要使用 "*"
分隔 "abfee"
和使用 "**"
分隔 "cd"
:
np.char.join(["*", "**"], ["abfee", "cd"])
array(['a*b*f*e*e', 'c**d'], dtype='<U9')
如果seq
字符串少于两个字符,则返回原始字符串:
np.char.join(["*", "**"], ["", "c"])
array(['', 'c'], dtype='<U1')
相关用法
- Python join()用法及代码示例
- Python Tableau jobs.get_by_id用法及代码示例
- Python json.dump()用法及代码示例
- Python json.dumps()用法及代码示例
- Python json.JSONEncoder.default用法及代码示例
- Python json.load()用法及代码示例
- Python json.loads()用法及代码示例
- Python cudf.core.column.string.StringMethods.is_vowel用法及代码示例
- Python NumPy fliplr方法用法及代码示例
- Python torch.distributed.rpc.rpc_async用法及代码示例
- Python torch.nn.InstanceNorm3d用法及代码示例
- Python sklearn.cluster.MiniBatchKMeans用法及代码示例
- Python pandas.arrays.IntervalArray.is_empty用法及代码示例
- Python tf.compat.v1.distributions.Multinomial.stddev用法及代码示例
- Python numpy.less()用法及代码示例
- Python Matplotlib.figure.Figure.add_gridspec()用法及代码示例
- Python tf.compat.v1.distribute.MirroredStrategy.experimental_distribute_dataset用法及代码示例
- Python Django File.save用法及代码示例
- Python NumPy squeeze方法用法及代码示例
- Python Sympy Permutation.list()用法及代码示例
- Python dask.dataframe.Series.apply用法及代码示例
- Python networkx.algorithms.shortest_paths.weighted.all_pairs_dijkstra_path用法及代码示例
- Python scipy.ndimage.binary_opening用法及代码示例
- Python NumPy char find方法用法及代码示例
- Python pyspark.pandas.Series.dropna用法及代码示例
注:本文由纯净天空筛选整理自Isshin Inada大神的英文原创作品 NumPy | join method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。