1. Home
  2. Docs
  3. golang
  4. 内置库(包-package)
  5. fmt


%x 副词参数 指定以十六进制的格式打印数组

%t 副词参数是用于打印布尔型数据


%q 一个单引号的字符字头,用Go语法安全地转义。


n := 32
sInt := fmt.Sprintf(%07d, n)


Sprintf formats according to a format specifier and returns the resulting string.



func Scanf

func Scanf(format string, a ...interface{}) (n int, err error)

Scanf scans text read from standard input, storing successive space-separated values into successive arguments as determined by the format. It returns the number of items successfully scanned. If that is less than the number of arguments, err will report why. Newlines in the input must match newlines in the format. The one exception: the verb %c always scans the next rune in the input, even if it is a space (or tab etc.) or newline.

Scanf 扫描从标准输入读取的文本,将连续的以空格分隔的值存储到由格式决定的连续参数中。它返回成功扫描的项目的数量。如果少于参数的数量,Err将报告原因。输入中的换行符必须与格式中的换行符一致。有一个例外:动词%c总是扫描输入中的下一个符文,即使它是一个空格(或制表符等)或新行。

Was this article helpful to you? Yes No

How can we help?