// Hello project main.go
package main
import (
"fmt"
)
var str string
func miss(name string) {
fmt.Print(len(name))
}
func main() {
str = "ling nizai nali" //字符串赋值
ch := str[0] // 取字符串的第一个字符
fmt.Printf("The length of \"%s\" is %d \n", str, len(str))
fmt.Printf("The first character of \"%s\" is %c.\n", str, ch)
}
有疑问加站长微信联系(非本文作者)