1 int size = 27;
2 String name = "Fido";
3 Dog myDog = new Dog(name, size);
4 int x = size - 5;
5 if (x < 15) {
6 myDog.bark(8);
7 }
8
9 while (x > 3) {
10 x -= 1;
11 myDog.play();
12 }
13
14 int[] numList = {2, 4, 6, 8};
15 System.out.print("Hello ");
16 System.out.println("Dog: " + name);
17
18 System.out.println(numList[1]);
19 if (numList[3] == 8) {
20 System.out.println("potato");
21 }
下面是去除 每行开头“行数”的 JavaScript程序。
// Node.js program to demonstrate
// the fsPromises.readFile() method
// Include fs module
const fs = require("fs");
const fsPromises = require("fs").promises;
async function readFile() {
const file = await fsPromises.readFile("./file.txt", "utf-8");
return file;
}
readFile().then((file) => {
const manyRows = file.split("\n");
const removePrefix = manyRows
.map((row) => {
return row.replace(/[0-9]+\s*/, "");
})
.join("\n");
fsPromises.writeFile("./result.txt", removePrefix);
});
标签:每行,const,fsPromises,System,readFile,fs,file,去掉,tools
From: https://www.cnblogs.com/nulixuexipython/p/18568493