package main
import "fmt"
func main() {
fmt.Print("Hello")
fmt.Print("World")
//会连续打印,但是它们之间没有空格或换行符
//Output: HelloWorld
fmt.Println("Hello", "World")
//输出多个内容,并在中间加空格
//Output: Hello World
name := "John"
age := 30
fmt.Printf("%s is %d years old.", name, age)
//格式化输出
//Output: John is 30 years old.
slice2 := []int{6, 7, 8}
fmt.Println(slice2)
//
}
fmt.Printf
%d:数字
%s:字符串
%v:占位符表示默认格式输出
a := [5]float32{1000.0, 2.0, 3.4, 7.0, 50.0} fmt.Printf("%v", a)
不能直接写
fmt.Printf(a)