Python provides an in-built function open()
which opens the file inside the program. You need to specify the name of the file which needs to be opened in a string within the parenthesis. By default, the file opens in reading
mode. You can specify different modes according to how you want to use the file in your program.
If you want to write to a file, you'd do something like this.
xxxxxxxxxx
var fs = require('fs');
fs.writeFile("filename.txt", "Writing in file", function(err) {
if (err) {
return console.log(err);
}
});
OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment