zhiqingstudy

Be a young person with knowledge and content

Use the fs. writeFile() method to write content to the specified file. The syntax format is as follows:

fs.writeFile(file,data[,options],callback)

Parameter interpretation:

File: string specifying a file path, representing the file storage path, a required parameter

Data: content to be written, required parameter

Options: What format to write the file in? Optional parameter. The default value is utf8

Callback: the callback function after the file is written, a required parameter

// 1.导入fs文件系统模块
const fs=require('fs')
// 2.调用fs.writeFile()方法,写入文件内容
//  参数一:指定一个文件路径的字符串,表示文件的存放路径,必选参数
//  参数二:要写入的内容,必选参数
//  参数三:文件写入完成后的回调函数,必选参数
fs.writeFile('./file.txt','hello Node.js',function(err,datastr){
    console.log(err)
})
comment
head sculpture
Code:
Related

The art of interpersonal communication and communication

A code of conduct that regulates and regulates interpersonal relationships

The importance of interpersonal relationships




Unless otherwise specified, all content on this website is original. If the reprinted content infringes on your rights, please contact the administrator to delete it
Contact Email:2380712278@qq.com

Filing number:皖ICP备19012824号