英文:
Golang Fprint* what does the f stand for
问题
fmt
包提供了一些用于字符串格式化的函数。
我相当确定Sprint*
代表字符串打印。
Print*
写入到标准输出(STDOUT)。
Fprint*
函数中的F
代表什么意思?
英文:
The fmt
package has some functions for string formatting.
Sprint*
I am pretty sure stands for string print.
Print*
writes to STDOUT
What does the F
stand for with the Fprint*
functions?
答案1
得分: 16
"f"代表"file",这是C/Unix的一个术语。当然,Fprint
可以写入任意的Writer
,但在Unix世界中,文件是一个相当通用的概念,可以指代从"普通"文件到套接字(流)或程序生成的数据等几乎任何东西(在任何负面评价之前 - 是的,我知道我有点过于简化,但问题不是关于Unix文件概念的,所以...)
fmt函数的命名与C的命名类似,以便让已经熟悉它们的C程序员更容易使用。
英文:
The "f" stands for "file" - it's a C/Unix-ism. Of course Fprint
can write to arbitrary Writer
s, but in the Unix world file is a pretty generic concept and can refer to pretty much anything from "normal" files to socket (streams) or data generated by programs (before any downvotes - yes, I know I'm a bit oversimplifying things, but the question wasn't about the Unix concept of a file so...)
The fmt function names are similar to the C names to ease C programmers already familiar with them in.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论