Add gitignore and initial project files
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
# JavaScript 基础
|
||||
|
||||
JavaScript 是一种轻量级的解释型编程语言,支持面向对象、命令式和声明式编程。
|
||||
|
||||
## 数据类型
|
||||
|
||||
JavaScript 有以下几种基本数据类型:
|
||||
|
||||
- `Number` - 数字
|
||||
- `String` - 字符串
|
||||
- `Boolean` - 布尔值
|
||||
- `null` - 空值
|
||||
- `undefined` - 未定义
|
||||
- `Symbol` - 符号(ES6)
|
||||
- `BigInt` - 大整数
|
||||
|
||||
## 代码示例
|
||||
|
||||
```javascript
|
||||
// Hello World
|
||||
function greet(name) {
|
||||
return `Hello, ${name}!`;
|
||||
}
|
||||
|
||||
console.log(greet('World'));
|
||||
|
||||
// 箭头函数
|
||||
const add = (a, b) => a + b;
|
||||
console.log(add(1, 2)); // 3
|
||||
```
|
||||
|
||||
## Promise 和 async/await
|
||||
|
||||
```javascript
|
||||
// Promise 示例
|
||||
function fetchData(url) {
|
||||
return fetch(url)
|
||||
.then(response => response.json())
|
||||
.then(data => console.log(data))
|
||||
.catch(error => console.error('Error:', error));
|
||||
}
|
||||
|
||||
// async/await 写法
|
||||
async function fetchDataAsync(url) {
|
||||
try {
|
||||
const response = await fetch(url);
|
||||
const data = await response.json();
|
||||
console.log(data);
|
||||
} catch (error) {
|
||||
console.error('Error:', error);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 数组方法
|
||||
|
||||
| 方法 | 描述 | 返回值 |
|
||||
|------|------|--------|
|
||||
| `map()` | 映射每个元素 | 新数组 |
|
||||
| `filter()` | 过滤元素 | 新数组 |
|
||||
| `reduce()` | 累加计算 | 单个值 |
|
||||
| `forEach()` | 遍历元素 | undefined |
|
||||
|
||||
> **提示**: 使用现代 JavaScript 特性可以让代码更简洁易读。
|
||||
@@ -0,0 +1,43 @@
|
||||
# Python 学习笔记
|
||||
|
||||
Python 是一门优雅且强大的编程语言。
|
||||
|
||||
## 基本语法
|
||||
|
||||
```python
|
||||
# 列表推导式
|
||||
squares = [x**2 for x in range(10)]
|
||||
print(squares) # [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
|
||||
|
||||
# 字典推导式
|
||||
word_lengths = {word: len(word) for word in ['hello', 'world', 'python']}
|
||||
print(word_lengths)
|
||||
```
|
||||
|
||||
## 装饰器
|
||||
|
||||
```python
|
||||
def timer(func):
|
||||
def wrapper(*args, **kwargs):
|
||||
import time
|
||||
start = time.time()
|
||||
result = func(*args, **kwargs)
|
||||
print(f"{func.__name__} took {time.time() - start:.4f}s")
|
||||
return result
|
||||
return wrapper
|
||||
|
||||
@timer
|
||||
def slow_function():
|
||||
import time
|
||||
time.sleep(1)
|
||||
return "Done"
|
||||
|
||||
print(slow_function())
|
||||
```
|
||||
|
||||
## 常用库
|
||||
|
||||
1. **NumPy** - 科学计算
|
||||
2. **Pandas** - 数据分析
|
||||
3. **Flask** - Web 框架
|
||||
4. **Requests** - HTTP 请求
|
||||
Reference in New Issue
Block a user