格式输出由一系列定义在 std::fmt 中的宏提供。

包含:

format! : 输出格式化的字符串。

print!  : 输出格式化的字符串到控制台(终端)
println!: 添加一个换行,输出格式化的字符串到控制台(终端)

println!("Guess the number!");
 

输出:

Guess the number!

println!("{} days", 31);
 

输出:

31 days

println!("{0}, this is {1}. {1}, this is {0}", "Alice", "Bob");
 

输出:

Alice, this is Bob. Bob, this is Alice

println!("{subject} {verb} {object}",
object="the lazy dog",
subject="the quick brown fox",
verb="jumps over");

输出:

the quick brown fox jumps over the lazy dog

println!("{} of {:b} people know binary, the other half don't", 1, 2);
 

输出:

1 of 10 people know binary, the other half don't

println!("{number:>width$}", number=1, width=6);
 

输出:

“     1”  // 引號是为了显示数字1的前面有五个空白字符而加上的,实际没有。

println!("{number:>0width$}", number=1, width=6);
 

输出:

000001

println!("My name is {0}, {1} {0}.”, "Bond","James");
 

输出:

My name is Bond, James Bond

很多其它语法:http://doc.rust-lang.org/std/fmt/

Rust 格式输出的更多相关文章

  1. C 格式输出

    1 一般格式    printf(格式控制,输出表列)    例如:printf("i=%d,ch=%c\n",i,ch);    说明:    (1) “格式控制”是用双撇号括起 ...

  2. 在现有的图像处理软件中融合dxf格式输出

    在现有的图像处理软件中融合dxf格式输出 dxf格式是autocade的支持格式.如果将现有图像识别的结果导出到dxf格式,就能够使用autocad的强大功能进行后续处理. dxf的格式比较复杂,开源 ...

  3. 《The Linux Command Line》 读书笔记03 ls命令与长格式输出解释 文件权限

    ls命令与长格式输出解释 文件权限 ls命令 ls 命令用于列出目录内容,不带参数时列出当前工作目录的内容,也可以指定目标目录(可以指定多个),列出目标目录下的内容. ls命令的参数 ls -l 长格 ...

  4. PAT 1006. 换个格式输出整数 (15)

    让我们用字母B来表示"百".字母S表示"十",用"12...n"来表示个位数字n(<10),换个格式来输出任一个不超过3位的正整数.例 ...

  5. PAT乙级 1006. 换个格式输出整数 (15)

    1006. 换个格式输出整数 (15) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 让我们用字母B来表示“百” ...

  6. PAT (Basic Level) Practise:1006. 换个格式输出整数

    [题目链接] 让我们用字母B来表示“百”.字母S表示“十”,用“12...n”来表示个位数字n(<10),换个格式来输出任一个不超过3位的正整数.例如234应该被输出为BBSSS1234,因为它 ...

  7. C#常用格式输出

    ylbtech- .NET-Basic:C#常用格式输出 C#常用格式输出 1.A,相关概念返回顶部 using System; namespace Test { class Formating { ...

  8. PAT乙级真题1006. 换个格式输出整数 (15)(解题)

    原题: 让我们用字母B来表示“百”.字母S表示“十”,用“12...n”来表示个位数字n(<10),换个格式来输出任一个不超过3位的正整数.例如234应该被输出为BBSSS1234,因为它有2个 ...

  9. PAT-乙级-1006. 换个格式输出整数 (15)

    1006. 换个格式输出整数 (15) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 让我们用字母B来表示“百” ...

随机推荐

  1. POJ 1741 树分治

    题目链接[http://poj.org/problem?id=1741] 题意: 给出一颗树,然后寻找点对(u,v)&&dis[u][v] < k的对数. 题解: 这是一个很经典 ...

  2. 【UOJ #105】【APIO2014】Beads and wires

    http://uoj.ac/problem/105 好神的dp啊. 确定一个点为根之后,蓝线只能是竖着的,不能横跨兄弟. 枚举每个点为根进行树形dp是\(O(n^2)\)的,\(f(x,0/1)\)表 ...

  3. HDU1251 统计难题 trie树 简单

    http://acm.hdu.edu.cn/showproblem.php?pid=1251 题意: 找前缀数量 裸模板 #include<cstdio> #include<cstr ...

  4. 【二分图最大匹配】【匈牙利算法】zoj3988 Prime Set

    题意:给你n个正整数,一对和为素数的数为一个合法数对.你选不超过K个合法数对,使得你选的数对涉及到的数的数量最大化.输出这个值. 所有1之间是可以任意两两配对的. 把奇数放在左侧,偶数放在右侧. 考虑 ...

  5. 【BZOJ】1042: [HAOI2008]硬币购物

    1042: [HAOI2008]硬币购物 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 3307  Solved: 2075[Submit][Stat ...

  6. CROC 2016 - Elimination Round (Rated Unofficial Edition) C. Enduring Exodus 二分

    C. Enduring Exodus 题目连接: http://www.codeforces.com/contest/655/problem/C Description In an attempt t ...

  7. CentOS 6.9/7通过yum安装指定版本的Tomcat

    说明:通过yum好处其实很多,环境变量不用配置,配置文件放在大家都熟悉的地方,通过rpm -ql xxx可以知道全部文件的地方等等. 一.安装Tomcat(8+) // 下载脚本 # git clon ...

  8. HDU 4685 Prince and Princess (2013多校8 1010题 二分匹配+强连通)

    Prince and Princess Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Othe ...

  9. ADC for programmable logic uses one capacitor

    Many electronic devices require user input for setting the application properties. Typical input dev ...

  10. How to Distinguish a Physical Disk Device from an Event Message

    https://support.microsoft.com/en-us/help/159865  https://support.microsoft.com/en-us/help/244780/inf ...