The difference between 4, Printf and the Println

Println () - a section of the processing, automatic line feed

Printf () --- formatted output, on the location of the contents of the variable of% d

package main

import "fmt" //gmt.Pringln()

func main() {
    a := 10

    fmt.Println("a = ", a)

    fmt.Printf("a = %d\n", a)
}

 

package main

import "fmt" //gmt.Pringln()

func main() {
    a := 10
    b := 20
    c := 30
    fmt.Println("a = ", a)

    fmt.Printf("a = %d\n", a)
    
    fmt.Println("a = ", a, "b = ", b, "c = ", c)
    fmt.Printf("a=%d, b=%d, c=%d", a, b, c)
}

 

Guess you like

Origin www.cnblogs.com/zyqy/p/11239497.html