Rust字符串数字左侧补零对齐追加保存到文本
use std::fs::OpenOptions;
use std::io::prelude::*;
fn main() {
let mut f = OpenOptions::new().create(true).append(true).open("test.txt").unwrap();
let mut i:u32 = 0;
let mut n3:String;
while i < 8 {
n3 = format!("{:0>8}{}",i,"\n");
f.write(n3.as_bytes()).unwrap();
i+=1;
}
}