Print and Println
are similar to each other, only differ in format
- There will be blank lines between each item printed by Println, but not by Print, for example:
fmt.Println("go","python","php","javascript") // go python php javascript
fmt.Print("go","python","php","javascript") // gopythonphpjavascript
- Println will automatically wrap, Print will not, for example:
fmt.Println("hello")
fmt.Println("world")
// hello
// world
fmt.Print("hello")
fmt.Print("world")
// helloworld
Println 和 Printf
func main() {
a:=10
b:=20
c:=30
fmt.Println("a=", a , ",b=" , b , ",c=" , c)
fmt.Printf("a=%d,b=%d,c=%d" , a , b , c)
}
% d is a placeholder, representing the decimal representation of a number. The placeholders in Printf correspond one-to-one with the following numeric variables. More placeholder reference: click here