fmt 包
Print 函数
go
package main
import "fmt"
func main() {
fmt.Print("hello, world\n")
}1
2
3
4
5
6
7
2
3
4
5
6
7
Print 函数会打印传入的字符串,但不会自动添加换行符。
Println 函数
go
package main
import "fmt"
func main() {
fmt.Println("hello, world")
}1
2
3
4
5
6
7
2
3
4
5
6
7
Println 函数会打印传入的字符串,并自动添加换行符。
Printf 函数
go
package main
import "fmt"
func main() {
fmt.Printf("hello, world\n")
}1
2
3
4
5
6
7
2
3
4
5
6
7
Printf 函数会格式化打印传入的字符串,但不会自动添加换行符。

share121