Rust 格式输出
来源:互联网 发布:唱歌下载什么软件 编辑:程序博客网 时间:2024/05/21 15:49
格式输出由一系列定义在 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/
0 0
- Rust 格式输出
- Rust: 逆序输出&str
- rust
- 输出格式
- 格式输出
- 输出格式
- 输出格式
- 输出格式
- 输出格式
- 输出格式
- 输出格式
- 输出格式
- 数据输出控制输出格式
- Rust:Programming Rust:所有权
- 关于输出日期格式
- 输出固定的格式
- asp输出excel格式
- printf输出格式
- int型转string型(不断拓展中)
- rm和rmdir 删除目录
- _stdcall 调用类型 函数参数压栈方式为什么是从右到左的?
- Android Activity生命周期详解
- CentOS下SVN服务的启动与关闭
- Rust 格式输出
- PreparedStatement
- 数据库基础
- CentOS常用的文件操作命令总结
- GCD详解
- Objective-C总Runtime的 消息机制
- AS版本手动升级
- htons(), ntohl(), ntohs(),htons()
- h264 分析工具