Add gitignore and initial project files
This commit is contained in:
@@ -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