当前位置: 首页 > news >正文

go中Println和Printf的区别

在这里插入图片描述
Don’t worry , just coding!
内耗与overthinking只会削弱你的精力,虚度你的光阴,每天迈出一小步,回头时发现已经走了很远。

go中Println和Printf的区别

package mainimport (
"fmt"
)//TIP To run your code, right-click the code and select <b>Run</b>. Alternatively, click
// the <icon src="AllIcons.Actions.Execute"/> icon in the gutter and select the <b>Run</b> menu item from here.func main() {
//TIP Press <shortcut actionId="ShowIntentionActions"/> when your caret is at the underlined or highlighted text
// to see how GoLand suggests fixing it.
s := "gopher"
fmt.Println("Hello and welcome, %s!", s)
fmt.Printf("Hello and welcome, %s!\n", s)for i := 1; i <= 5; i++ {//TIP You can try debugging your code. We have set one <icon src="AllIcons.Debugger.Db_set_breakpoint"/> breakpoint// for you, but you can always add more by pressing <shortcut actionId="ToggleLineBreakpoint"/>. To start your debugging session,// right-click your code in the editor and select the <b>Debug</b> option.fmt.Println("i =", 100/i)}
}//TIP See GoLand help at <a href="https://www.jetbrains.com/help/go/">jetbrains.com/help/go/</a>.
// Also, you can try interactive lessons for GoLand by selecting 'Help | Learn IDE Features' from the main menu.

输出:
在这里插入图片描述

区别:Println会显示%s这个占位字符本身,Printf不会显示

掌握知识的最好方式就是教会别人,每篇文章都讲清楚一个知识点,欢迎留言我一起讨论。

http://www.lryc.cn/news/477295.html

相关文章:

  • C++现代教程七之模块
  • AVLTree
  • Java面向对象 C语言字符串常量
  • SpringBoot+Thymeleaf电商系统
  • 了解数据库并发产生的问题
  • openstack之guardian介绍与实例创建过程
  • 新一代跟踪器StrongSORT: Make DeepSORT Great Again论文解析—让 DeepSORT 再次伟大
  • SAP ABAP开发学习——RFC
  • Elasticsearch里的索引index是什么概念?(ChatGPT回答)
  • 安全性测试
  • ComfyUI和Photoshop相结合,PS内实现:文生图,图生图,高清放大,局部重绘,面部修复,设计师福音
  • 使用 map 和 reduce 提取对象数组中的 id 并组成新数组
  • Zero-Shot Relational Learning for Multimodal Knowledge Graphs
  • AUTOSAR COM 模块的主要功能导读以及示例
  • VMware下Centos7虚拟机数据盘/data目录(非lvm)不停机热扩容实操
  • 易盾增强版滑块识别/易盾识别/滑块识别/增强版滑块识别/易盾滑块本地识别
  • DMRl-Former用于工业过程预测建模和关键样本分析的数据模式相关可解释Transformer网络
  • 向量模型Jina Embedding: 从v1到v3论文笔记
  • Spring学习笔记(一)
  • Java编程基础
  • C++【string类,模拟实现string类】
  • Jupyter lab 打开时默认使用 Notebook 而不是浏览器
  • 【linux】ubunda repo是什么
  • 【MySQL】深层理解索引及特性(重点)--下(12)
  • 无人机声学侦测算法详解!
  • git 提交仓库
  • 基于大语言模型(LLM)自主Agent 智能体综述
  • 使用命令行管理 Windows 环境变量
  • AUTODL配置百度网盘数据传输
  • LeetCode46. 全排列(2024秋季每日一题 57)