feat(*): 代码仓库初始化
This commit is contained in:
1
Server/2/.gitignore
vendored
Normal file
1
Server/2/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
text.txt
|
||||
20
Server/2/README.md
Normal file
20
Server/2/README.md
Normal file
@@ -0,0 +1,20 @@
|
||||
<!--
|
||||
Copyright (c) 2025 zhilv
|
||||
|
||||
This software is released under the MIT License.
|
||||
https://opensource.org/licenses/MIT
|
||||
-->
|
||||
|
||||
## `Python` 网络爬虫基础教程
|
||||
|
||||
### 文件介绍
|
||||
|
||||
```sh
|
||||
.
|
||||
├── 1 # 课堂作业1
|
||||
├── 2 # 课堂作业2
|
||||
└── tests # 实验文件夹
|
||||
├── test1 # 实验一
|
||||
├── test2 # 实验二
|
||||
└── test3 # 实验三
|
||||
```
|
||||
6
Server/2/main.js
Normal file
6
Server/2/main.js
Normal file
@@ -0,0 +1,6 @@
|
||||
const utils = require("./utils");
|
||||
const fs = require("fs");
|
||||
|
||||
const text = fs.readFileSync(__dirname + "/text.txt", "utf8");
|
||||
|
||||
console.log(utils.word_count(text));
|
||||
12
Server/2/utils.js
Normal file
12
Server/2/utils.js
Normal file
@@ -0,0 +1,12 @@
|
||||
const word_count = function (text) {
|
||||
const text_list = text.replace(/[、\r?\n,,\s]+/g, " ").split(" ");
|
||||
let word_obj = {};
|
||||
for (const word of text_list) {
|
||||
word_obj[word] = (word_obj[word] || 0) + 1;
|
||||
}
|
||||
return word_obj;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
word_count,
|
||||
};
|
||||
Reference in New Issue
Block a user