LoginSignup
0
0

More than 1 year has passed since last update.

Goでの書式付き出力

Posted at

%sを使う

package main

import "fmt"

func main() {

    weather := "晴れ"
    fmt.Printf("今日の天気は%sです", weather) // 出力結果:今日の天気は晴れです
}

整数の場合は%dを使う

package main

import "fmt"

func main() {
    month := 6
    day := 19
    
    fmt.Printf("今日は、%d月%d日です", month, day)
    
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0