Go 语言——字符串、数据的格式化输出(Printf)
来源:互联网 发布:手机阅读软件免费下载 编辑:程序博客网 时间:2024/06/07 00:08
直接看代码:
//字符串输出var sayHi string = "hello world"fmt.Println(sayHi)// \ 转义fmt.Println("hello \nworld")fmt.Println("hello \"world")// ` 可以将字符串按设定格式输出fmt.Println(`hello "world`)//浮点类型格式输出var pi = 3.1fmt.Printf("%f \n",pi);//保留两位小数fmt.Printf("%.2f \n",pi)var age = 30//整数 %dfmt.Printf("my sge is %d \n",age)//输出整数的二进制值fmt.Printf("30`s binary %b \n",age)//输出整数的八进制值fmt.Printf("30`s octal %o \n",age)//输出整数的十六进制值fmt.Printf("30`s hex %x \n",age)//格式化输出布尔类型var married = truefmt.Printf("is married %t \n",married)//字符串输出var sayHi = "hi"fmt.Printf("he say '%s' \n",sayHi)//输出变量类型fmt.Printf("'age' type is %t \n",age)fmt.Printf("'married1111' type is %t \n",married)fmt.Printf("'married2222' type is %T \n",married)
阅读全文
0 0
- Go 语言——字符串、数据的格式化输出(Printf)
- printf格式化输出字符串
- C语言的格式化输出函数printf
- Python 字符串格式化输出(format/printf)
- Python:字符串格式化输出(format/printf)
- c语言格式化输出函数printf()
- c语言格式化输出函数printf()
- C语言 printf输出字符串数据
- go语言字符串格式化
- printf()的格式化输出
- printf的格式化输出
- c语言printf格式化输出
- go json数据格式化输出
- C语言中printf格式化输出函数(转载)
- printf的标准格式化输出
- java printf的格式化输出
- awk字符串函数(printf格式化输出) -- shell
- 格式化输出(printf,sprintf)
- Elasticsearch 存放地理信息数据+百度POI分析
- @Component、@Repository、@Service、@Controller、@Scope("prototype")区别
- leetcode500 Java1.8 Stream
- Animation之TranslateAnimation(平移动画)
- pwnable.tw calc writeup
- Go 语言——字符串、数据的格式化输出(Printf)
- Sting和StringBuffer的相互转换
- 利用python进行数据分析小笔记——分析‘[rec['tz'] for rec in records if 'tz' in rec]’ python
- 2017.9.27 书架 思考记录
- 基本数据类型之间的相互转换
- Linux C/C++编程一站式学习中输出菱形
- Codeforces 274B 【树形DP】
- 用循环写百钱买百鸡
- 考试系统