2.5 tabwriter 格式化输出

package main

import (
	"fmt"
	"os"
	"text/tabwriter"
)

func main() {

	w := tabwriter.NewWriter(os.Stdout, 15, 0, 1, ' ', tabwriter.AlignRight)
	fmt.Fprintln(w, "username\tfirstname\tlastname\t")
	fmt.Fprintln(w, "sohlich\tRadomir\tSohlich\t")
	fmt.Fprintln(w, "novak\tJohn\tSmith\t")
	w.Flush()

}

/*
   username      firstname       lastname
    sohlich        Radomir        Sohlich
      novak           John          Smith



*/

posted on 2018-03-21 23:17  cucy_to  阅读(170)  评论(0编辑  收藏  举报

导航