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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。