GO标记
Go 程序可以由多个标记组成,可以是关键字,标识符,常量,字符串,符号。如以下 GO 语句由 6 个标记组成:
fmt.Println("Hello, World!")
6 个标记是(每行一个):
1. fmt
2. .
3. Println
4. (
5. "Hello, World!"
6. )
格式化:
package main
import "fmt" //fmt包中提供格式化,输出,输入的函数.
func main() {
//要求:要求:请使用一句输出语句,达到输入如下图形的效果
fmt.Println("姓名\t年龄\t籍贯\t地址\njohn\t20\t河北\t北京")
}
制表符:
package main
import "fmt"
func main() {
//制表符
fmt.Println("姓名\t性别\t籍贯\t住址\ntom\t男\t天津\t北京")
}
代码demo
package main
import "fmt" //fmt包中提供格式化,输出,输入的函数.
//这是一个main函数,是程序入口
func main() {
//演示转义字符的使用 \t
fmt.Println("tom\tjack")
// 如果希望一次性注释 ctrl + / 第一次表示注释,第二次表示取消注释
fmt.Println("hello\nworld")
fmt.Println("C:\\Users\\Administrator\\Desktop\\Go语言核心编程课程\\资料")
fmt.Println("tom说\"i love you\"")
// \r 回车,从当前行的最前面开始输出,覆盖掉以前内容
fmt.Println("天龙八部雪山飞狐\r张飞厉害")
fmt.Println("helloworldhelloworldhelloworldhelloworl\n",
"dhelloworldhelloworldhelloworldhelloworldhelloworldhellowor\n",
"ldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworl\n",
"dhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhel\n",
"loworldhelloworldhelloworldhelloworldhelloworldhelloworldhellowor\n",
"ldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworld")
//var num = 2 + 4 * 5
}