//Rust 文件与 IO use std::io::prelude::; use std::fs; use std::io::Write; use std::fs::OpenOptions; use std::thread; extern crate time; //crate是一个很重要的概念,类似于是package(包)的概念 use time::;
fn main() { let start = time::now();//获取开始时间
let text = fs::read_to_string("E:\\201896333\\96333\\2020\\00 MyWork\\003 Rust\\code\\HiRust2020\\test.txt").unwrap();
let content = fs::read("E:\\201896333\\96333\\2020\\00 MyWork\\003 Rust\\code\\HiRust2020\\test.txt").unwrap();
//println!("{:?}", content);
let fileurl="E:\\201896333\\96333\\2020\\00 MyWork\\003 Rust\\code\\HiRust2020\\textt.txt";
//writelog("gjh","test write log");
/*
let mut buffer = [0u8; 5];
let mut file = fs::File::open(&fileurl).unwrap();
file.read(&mut buffer).unwrap();
println!("{:?}", buffer);
file.read(&mut buffer).unwrap();
println!("{:?}", buffer);
fs::write(&fileurl, &text)
.unwrap();*/
let end = time::now();//获取结束时间
let duration = end - start;
println!("开始时间:{:?}",start);
println!("结束时间:{:?}",end);
println!("耗时:{}",duration);
}
1
共 0 条评论, 1 页
评论区
写评论还没有评论