Files
go-study/main/pu.go
2024-08-01 23:40:06 +08:00

22 lines
400 B
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package main
import (
"fmt"
)
func main() {
//定义切片make函数的三个参数1.切片类型。2.切片的长度
slice := make([]int, 4, 20)
fmt.Println(slice)
fmt.Println(len(slice))
fmt.Println(cap(slice))
slice[0] = 66
slice[1] = 88
slice1 := []int{3, 4, 5}
fmt.Println(slice1)
//按照数组的方式操作
for key, value := range slice1 {
fmt.Println(key, value)
}
}