最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

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

Go 標(biāo)準(zhǔn)包 strings 學(xué)習(xí)(3)Cut,CutPrefix,CutSuffix

2023-04-21 13:34 作者:取悅疾風(fēng)  | 我要投稿

官網(wǎng)

https://pkg.go.dev/strings@go1.20.3 作者:取悅疾風(fēng)?

func?Cut

Cut slices s around the first instance of sep, returning the text before and after sep. The found result reports whether sep appears in s. If sep does not appear in s, cut returns s, "", false.

在sep的第一個實例周圍切割切片s,返回sep前后的文本。發(fā)現(xiàn)的結(jié)果報告sep是否出現(xiàn)在s中。如果sep沒有出現(xiàn)在s中,則Cut返回s, "", false。

沒看懂...

舉例

輸出

理解

返回前一個字符串是否包含后一個字符串,并且輸出前一個字符串在刪除后面的字符串后的前面,后面2部分

func?CutPrefix

CutPrefix returns s without the provided leading prefix string and reports whether it found the prefix. If s doesn't start with prefix, CutPrefix returns s, false. If prefix is the empty string, CutPrefix returns s, true.

翻譯

CutPrefix返回沒有提供的前導(dǎo)前綴字符串的s,并報告它是否找到了前綴。如果s不以prefix開頭,則CutPrefix返回s, false。如果prefix是空字符串,CutPrefix返回s, true。

說明

返回s字符串去除prefix字符串后的字符串,并返回是否找到

func?CutSuffix

和上一個差不多

返回s字符串去除suffix字符串后的字符串,并返回是否找到

本質(zhì)上都是返回一個string去除另一個string后的結(jié)果

Go 標(biāo)準(zhǔn)包 strings 學(xué)習(xí)(3)Cut,CutPrefix,CutSuffix的評論 (共 條)

分享到微博請遵守國家法律
宜良县| 安吉县| 朝阳市| 临朐县| 务川| 即墨市| 天峨县| 沙坪坝区| 荔浦县| 镇平县| 当雄县| 黑山县| 大厂| 吐鲁番市| 专栏| 琼海市| 织金县| 洪湖市| 桐梓县| 临武县| 贞丰县| 淄博市| 龙州县| 霍林郭勒市| 永善县| 古丈县| 仁怀市| 通州区| 巴东县| 铜鼓县| 新巴尔虎右旗| 将乐县| 镇安县| 辰溪县| 辽阳市| 墨竹工卡县| 合水县| 绍兴县| 邵武市| 集安市| 拉孜县|