package main
import "fmt"
func main(){
fmt.Print("My weight on the surface of Mars is ")
fmt.Print(149.0 * 0.3783)
fmt.Print(" lbs, and I would be ")
fmt.Print(41 * 365 / 687)
fmt.Print(" years old.")
fmt.Println()
fmt.Println("My weight on the surface of Mars is", 149.0 * 0.3783, "lbs, and I would be", 41 * 365.2425/687, "years old.")
fmt.Println("------------------------------------格式化打印--------------------------------")
fmt.Printf("My weight on the surface of Mars is %v lbs,", 149.0 * 0.3783)
fmt.Printf(" and I would be %v years old.\n", 41 * 365 / 687)
fmt.Printf("My weight on the surface of %v is %v lbs.\n", "Earth", 149.0)
fmt.Println("-------------使用Printf对齐文本-----------")
fmt.Printf("%-15v $%4v\n", "SpaceX", 94)
fmt.Printf("%-15v $%4v\n", "Virgin Galactic", 100)
}
转载请注明原文地址:https://blackberry.8miu.com/read-44930.html