五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

Go 標準包 strings 學習(6) Join,LastIndex,LastIndexAny,LastIndexByte,L

2023-05-06 13:08 作者:取悅疾風  | 我要投稿

https://pkg.go.dev/strings@go1.20.4#Join

func?Join

Join concatenates the elements of its first argument to create a single string. The separator string sep is placed between elements in the resulting string.

Join將其第一個參數(shù)的元素連接起來以創(chuàng)建單個字符串。分隔字符串sep放置在結(jié)果字符串的元素之間。

例子

輸出

foo, bar, baz

理解:將一個切片里面的數(shù)據(jù)轉(zhuǎn)為一整個字符串,并使用傳入的第二個string分割

func?LastIndex

LastIndex returns the index of the last instance of substr in s, or -1 if substr is not present in s.

LastIndex返回s中substr最后一個實例的索引,如果substr不存在于s中,則返回-1。

例子

輸出

0 3 -1

理解

傳入2個字符串,第一個是需要被搜索的字符串,第二個是需要在第一個字符串里面進行檢索的字符串,返回第二個字符串在第一個字符串中最后一次出現(xiàn)的下標位置

func?LastIndexAny

LastIndexAny returns the index of the last instance of any Unicode code point from chars in s, or -1 if no Unicode code point from chars is present in s.

LastIndexAny返回s中字符的任何Unicode碼點的最后一個實例的索引,如果s中沒有字符的Unicode碼點,則返回-1。

例子

輸出

4 8 -1

理解

返回第二個字符串里的任意一個字符,在第一個字符串中,最后一次出現(xiàn)的下標

func?LastIndexByte

LastIndexByte returns the index of the last instance of c in s, or -1 if c is not present in s.

LastIndexByte返回s中c的最后一個實例的索引,如果s中不存在c,則返回-1。

例子

輸出

10 8 -1

理解

返回輸入的字符在字符串中最后一次出現(xiàn)的下標位置

func?LastIndexFunc

LastIndexFunc returns the index into s of the last Unicode code point satisfying f(c), or -1 if none do.

LastIndexFunc返回滿足f(c)的最后一個Unicode碼點到s的索引,如果不滿足則返回-1。

例子

輸出

5 2 -1

理解

返回字符串在哪一個下標位置符合指定的規(guī)則

Go 標準包 strings 學習(6) Join,LastIndex,LastIndexAny,LastIndexByte,L的評論 (共 條)

分享到微博請遵守國家法律
涞源县| 巴塘县| 镇安县| 开阳县| 枣强县| 洪雅县| 慈利县| 饶河县| 龙州县| 罗源县| 阿拉尔市| 清徐县| 卢湾区| 茶陵县| 申扎县| 尤溪县| 广东省| 兴国县| 新巴尔虎左旗| 卢湾区| 东乡族自治县| 德钦县| 读书| 龙陵县| 平昌县| 中山市| 大关县| 聂荣县| 齐河县| 景德镇市| 新建县| 江西省| 黄石市| 西安市| 兴山县| 赤峰市| 休宁县| 自治县| 长泰县| 昆山市| 闻喜县|