91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

字符串函數在golang中的使用

發布時間:2020-07-10 00:30:21 來源:網絡 閱讀:288 作者:PowerMichael 欄目:編程語言

package main

import (
    "fmt"
    "strings"
)

func main()  {
    //判斷父字符串是否包含子字符串,包含為真,否則為假
    fmt.Println("-------------------------------")
    fmt.Println("contains Function:", strings.Contains("Austrilia", "lia"))
    fmt.Println("contains Function:", strings.Contains("Austrilia", "mia"))

    //子字符串在父字符串中出現的次數
    fmt.Println("-------------------------------")
    fmt.Println("Count Function: ",strings.Count("Australia", "lia"))
    fmt.Println("Count Function: ",strings.Count("Australia", "A"))
    fmt.Println("Count Function: ",strings.Count("Australia", "Bu"))

    //判斷子字符串是否為父字符串的前綴
    fmt.Println("-------------------------------")
    fmt.Println("HasPrefix Function: ",strings.HasPrefix("Australia", "Bu"))
    fmt.Println("HasPrefix Function: ",strings.HasPrefix("Australia", "Aus"))

    ////判斷子字符串是否為父字符串的后綴
    fmt.Println("-------------------------------")
    fmt.Println("HasSuffix Function: ",strings.HasSuffix("Australia", "lia"))
    fmt.Println("HasSuffix Function: ",strings.HasSuffix("Australia", "tia"))

    //子字符串首次出現在父子符串的索引下標
    fmt.Println("-------------------------------")
    fmt.Println("Index Function:",strings.Index("Australia", "lia"))
    fmt.Println("Index Function: ",strings.Index("Australia", "a"))
    fmt.Println("Index Function: ",strings.Index("Australia", "A"))

    //連接函數,指定分隔符將字符串連接起來
    fmt.Println("-------------------------------")
    fmt.Println("Join Functions:",strings.Join([]string{"Austrilia", "Japen", "Germany"}, "-"))
    fmt.Println("Join Function: ",strings.Join([]string{"Australia","Japan","Germany"}," "))

    //重復函數,指定字符串重復出現的次數
    fmt.Println("-------------------------------")
    fmt.Println("Repeat Function:", strings.Repeat("Australia",3))

    //替換字符串函數,
    fmt.Println("-------------------------------")
    fmt.Println("Replace Function: ",strings.Replace("Australia ","a","b",1))
    fmt.Println("Replace Function: ",strings.Replace("Australia ","a","b",2))
    fmt.Println("Replace Function: ",strings.Replace("Aaustralia ","a","b",3))
    fmt.Println("Replace Function: ",strings.Replace("Australia ","A","B",1))
    fmt.Println("Replace Function: ",strings.Replace("Australia ","lia","pia",1))

    //分割函數,指定分隔符分隔字符串
    fmt.Println("-------------------------------")
    fmt.Println("Split Function:", strings.Split("Australia-Japan-Germany","-"))

    //把字符轉小寫
    fmt.Println("-------------------------------")
    fmt.Println("ToLower Function: ",strings.ToLower("Australia"))

    //把字符串轉大寫
    fmt.Println("-------------------------------")
    fmt.Println("ToUpper Function: ",strings.ToUpper("Australia"))

}
向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

靖宇县| 揭阳市| 安仁县| 雷山县| 赤水市| 永安市| 历史| 抚州市| 娱乐| 苏州市| 安宁市| 赣榆县| 雷波县| 津南区| 鄂托克前旗| 习水县| 沧源| 定襄县| 丹阳市| 山东省| 临邑县| 海口市| 浦北县| 洛阳市| 德清县| 太原市| 琼中| 和政县| 宣威市| 肥城市| 鹿泉市| 陇西县| 漳州市| 怀柔区| 平南县| 河间市| 邻水| 磴口县| 潞西市| 德惠市| 兴业县|