プログラミング言語によって違うのよ、これが。

Swift の String()。

👉 init(format:_:) | Apple Developer Documentation 
よく使われてるやつ。GitHub 調べ。
[
  String(format: "%02x", 255),
  // ff
  String(format: "%02X", 170),
  // AA
  String(format: "%02d", 1),
  // 01
  String(format: "% 5d", 2),
  //     2
  String(format: "%.2f", 1.2),
  // 1.20
  String(format: "%.2f", 1.204),
  // 1.20
  String(format: "%.2f", 1.205),
  // 1.21
  String(format: "%.0f", 1.23),
  // 1
  String(format: "%f", 3.12),
  // 3.120000
  String(format: "%+.2f", -123.5),
  // -123.50
  String(format: "%p", 3),
  // 0x3
  String(format: "%@", "x"),
  // x
  String(format: "%2$@ %1$@", "world", "Hello")
  // Hello world
].forEach {
  print($0)
}
知っておくだけで便利です。
👉 String Format Specifiers 
👉 String Format Specifiers 
👉 What are the supported Swift String format specifiers? - Stack Overflow 
 
		 
           
          


