五月天青色头像情侣网名,国产亚洲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的評論 (共 條)

分享到微博請遵守國家法律
汉沽区| 贵港市| 莆田市| 祁连县| 博乐市| 海原县| 民丰县| 茌平县| 蓬安县| 泸溪县| 莱州市| 凌云县| 卢氏县| 齐齐哈尔市| 汶川县| 万载县| 冷水江市| 台东市| 那曲县| 收藏| 凤冈县| 建阳市| 安徽省| 宣威市| 永顺县| 东阿县| 闻喜县| 和平区| 临潭县| 伽师县| 思茅市| 灵山县| 依兰县| 卢氏县| 绍兴县| 大理市| 黄石市| 泰来县| 乌兰察布市| 金坛市| 松桃|