fmt.Print() 默认标准输出

fmt.Print()语法

func fmt.Print(a ...any) (n int, err error)

go源码对fmt.Print()方法介绍

Print formats using the default formats for its operands and writes to standard output. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered.

Print()是golang标准库fmt中方法,会采用默认格式将参数格式化并写入标准输出。如果两个相邻的参数都不是字符串,那么将会在它们的输出之间添加空格。

fmt.Print()参数

参数描述
a将被格式化并写入标准输出的内容,个数不限,多个参数使用英文逗号隔开。

fmt.Print()方法返回值

写入的字节数和遇到的任何错误。

fmt.Print()方法实例代码

package main

import (
	"fmt"
)

func main() {
	web_name := "笨鸟工具"
	web_host := "x1y1z1.com"
	fmt.Print(web_name, web_host)

}

运行go文件,得到输出:

笨鸟工具x1y1z1.com

免责声明:内容仅供参考。


全栈后端 / go语法 :













Copyright © 2022-2024 笨鸟工具 x1y1z1.com All Rights Reserved.