zoukankan      html  css  js  c++  java
  • Go Example--格式化字符串

    package main
    
    import (
    	"fmt"
    	"os"
    )
    
    type point struct {
    	x, y int
    }
    
    func main() {
    	p := point{1, 2}
    	fmt.Printf("%v
    ", p)
    	fmt.Printf("%+v
    ", p)
    	fmt.Printf("%#v
    ", p)
    	fmt.Printf("%T
    ", p)
    	fmt.Printf("%t
    ", true)
    	fmt.Printf("%d
    ", 123)
    	fmt.Printf("%b
    ", 14)
    	fmt.Printf("%c
    ", 33)
    	fmt.Printf("%x
    ", 456)
    	fmt.Printf("%f
    ", 78.9)
    	fmt.Printf("%e
    ", 12340000.0)
    	fmt.Printf("%E
    ", 12340000.0)
    	fmt.Printf("%s
    ", ""string"")
    	fmt.Printf("%q
    ", ""string"")
    	fmt.Printf("%x
    ", "hex this")
    	fmt.Printf("%p
    ", &p)
    	fmt.Printf("|%6d|%6d|
    ", 12, 345)
    	fmt.Printf("|%6.2f|%6.2f|
    ", 1.2, 3.45)
    	fmt.Printf("|%-6.2f|%-6.2f|
    ", 1.2, 3.45)
    	fmt.Printf("|%6s|%6s|
    ", "foo", "b")
    	fmt.Printf("|%-6s|%-6s|
    ", "foo", "b")
    	s := fmt.Sprintf("a %s", "string")
    	fmt.Println(s)
    	fmt.Fprintf(os.Stderr, "an %s
    ", "error")
    }
    
  • 相关阅读:
    Spring--AOP
    Database--事务
    Neo4j--UNIQUE约束
    Neo4j--INDEX索引
    排序算法 目录
    数据结构 目录
    设计模式 目录
    建造者模式及应用举例
    模板模式以及应用举例
    真·随笔
  • 原文地址:https://www.cnblogs.com/promenader/p/9858518.html
Copyright © 2011-2022 走看看