工作记录4
node.js
(1)fs模块写入文件
异步写入文件:
fs.writeFile('example.txt', 'Hello, World!', (err) => {if (err) {console.error('Error writing file:', err);return;}console.log('File written successfully');
});
同步写入文件:
try {fs.writeFileSync('example.txt', 'Hello, World!');console.log('File written successfully');
} catch (err) {console.error('Error writing file:', err);
}
(2)http协议
(