golang输出的格式化打印
package main
import "fmt"
func main(){
//通用的格式
str:="jonson"
fmt.Printf("%T,%v\n",str,str)
//布尔
var booeanl = true
fmt.Printf("%T,%t\n",booeanl,booeanl)
//特殊字符
fmt.Printf("%%\n")
fmt.Printf("\"\n")
fmt.Printf("\\\n")
//整数
fmt.Printf("%T,%d\n",123,123)
fmt.Printf("%T,%6d\n",123,123) //6代表长度
fmt.Printf("%T,%06d\n",123,123)//0代表填充0
fmt.Printf("%T,%b\n",123,123) //二进制
fmt.Printf("%T,%o\n",123,123) //8进制
fmt.Printf("%T,%x\n",123,123) //16进制
fmt.Printf("%T,%#x\n",123,123) //前面加上0x
fmt.Printf("%T,%#o\n",123,123)//前面加上0
fmt.Printf("%T,%#X\n",123,123) //大写的X代表字母会大写
fmt.Printf("% d,% d\n",123,-123) //空格代表正数前方会预留一个空格
// 浮点数
fmt.Printf("%T,%f\n",123.456,123.456)
fmt.Printf("%T,%10f\n",123.456,123.456)//长度
fmt.Printf("%T,%.1f\n",123.456,123.456) //保留的小数位数
fmt.Printf("%T,%10.2f\n",123.456,123.456)
//字符串
fmt.Printf("%T,%s\n","jonson","jonson")
//字符串
fmt.Printf("%T,%c\n",'c',97)
}
-
版权声明: 本博客所有文章除特别声明外,均采用 CC BY 4.0 CN协议 许可协议。转载请注明出处!
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Operating System Algorithms
Nathan Adams、Elisha Chirchir / CreateSpace Independent Publishing Platform / 2017-4-21 / USD 39.15
Operating System Algorithms will walk you through in depth examples of algorithms that you would find in an operating system. Selected algorithms include process and disk scheduling.一起来看看 《Operating System Algorithms》 这本书的介绍吧!