2016年3月9日
nodejs
fs模块
fs.open('1.txt', 'r', function(err, fd) {
//console.log(err);
//console.log(fd);
if (err) {
console.log( '文件打开失败' );
} else {
console.log( '文件打开成功' );
console.log( fd );
}
});
//结果:
null
3
文件打开成功
3
fs.open('1.txt', 'r', function(err, fd) {
console.log(fd);
});
console.log("hello");
//结果
hello
3
//两个操作独自运行,打开文件需要一定时间,所以先输出"hello"。Last updated