12345678910111213141516171819202122232425262728293031323334353637383940 |
- import { writeFile, appendFile, readFile } from 'node:fs/promises';
- export async function writeFileAsync() {
- try {
- await writeFile('./log.txt', 'heheda');
- console.log('写入成功');
- } catch (error) {
- console.error('写入失败:', error);
- }
- }
- export async function appendFileAsync(data = '') {
- try {
- await appendFile('./log.append.txt', data);
- console.log('写入成功');
- } catch (error) {
- console.error('写入失败:', error);
- }
- }
- export async function readFileAsync() {
- try {
-
-
- let content = await readFile('./log.append.txt', 'utf8');
- console.log(content);
- } catch (error) {}
- }
|