Day 5: Python基础与JAVA对比

学习目标

  • 理解Python与JAVA的主要区别和相似之处
  • 掌握Python的基本语法和数据类型
  • 学习Python的面向对象编程特性
  • 了解Python生态系统和包管理
  • 能够将JAVA开发经验迁移到Python开发中

1. Python语言概述

1.1 Python简介

Python是一种高级、解释型、通用编程语言,由Guido van Rossum于1991年首次发布。Python强调代码可读性,使用缩进而非花括号来分隔代码块。

设计理念:Python的设计哲学强调代码的可读性和简洁性,其核心理念可以概括为"Python之禅"(The Zen of Python)。

# 可以通过以下命令查看Python之禅
import this

Python之禅的部分内容

  • 优美胜于丑陋
  • 显式胜于隐式
  • 简单胜于复杂
  • 复杂胜于晦涩
  • 可读性很重要

1.2 Python vs JAVA:基本对比

特性 Python JAVA
类型系统 动态类型 静态类型
编译/解释 解释执行 编译为字节码,JVM执行
语法风格 使用缩进表示代码块 使用花括号表示代码块
变量声明 无需声明类型 需要显式声明类型
内存管理 自动垃圾回收 自动垃圾回收
多线程 有GIL限制 完全支持
面向对象 支持但不强制 几乎所有代码都在类中
函数式特性 一等公民函数,lambda Java 8+支持lambda和函数式接口
使用场景 数据分析、AI/ML、Web、脚本 企业应用、Android、大型系统

1.3 为什么大模型开发选择Python

Python在大模型开发中的优势

  • 丰富的机器学习和深度学习库(TensorFlow, PyTorch等)
  • 简洁的语法,适合快速原型开发
  • 强大的数据处理能力(NumPy, Pandas等)
  • 活跃的AI研究社区和生态系统
  • 良好的C/C++集成能力,便于性能优化

JAVA在大模型开发中的局限

  • 机器学习库相对较少且不够成熟
  • 语法冗长,原型开发速度慢
  • 科学计算生态系统不如Python丰富
  • 研究社区较小

2. Python基本语法与JAVA对比

2.1 代码结构与风格

Python代码结构

  • 使用缩进表示代码块(通常是4个空格)
  • 无需分号结束语句
  • 注释使用#开头

JAVA代码结构

  • 使用花括号{}表示代码块
  • 语句以分号;结束
  • 注释使用//或/* */

对比示例

// JAVA示例
public class HelloWorld {
    public static void main(String[] args) {
        // 这是一个注释
        if (args.length > 0) {
            System.out.println("Hello, " + args[0]);
        } else {
            System.out.println("Hello, World");
        }
    }
}
# Python示例
def main(args):
    # 这是一个注释
    if len(args) > 0:
        print("Hello, " + args[0])
    else:
        print("Hello, World")

if __name__ == "__main__":
    import sys
    main(sys.argv[1:])

2.2 变量与数据类型

Python变量

  • 动态类型,无需声明
  • 变量名区分大小写
  • 命名约定:使用小写字母和下划线(snake_case)

JAVA变量

  • 静态类型,需要显式声明
  • 变量名区分大小写
  • 命名约定:使用驼峰命名法(camelCase)

基本数据类型对比

JAVA Python 说明
int, long int Python的整数没有大小限制
float, double float Python只有一种浮点类型
boolean bool True/False vs true/false
char, String str Python字符串是Unicode
array list Python列表更灵活,可变长度
N/A tuple 不可变序列
HashMap dict 键值对集合
HashSet set 无序不重复集合

示例对比

// JAVA变量示例
int count = 10;
double price = 23.45;
boolean isActive = true;
String name = "John";
int[] numbers = {1, 2, 3, 4, 5};
Map<String, Integer> ages = new HashMap<>();
ages.put("John", 30);
ages.put("Mary", 25);
# Python变量示例
count = 10
price = 23.45
is_active = True
name = "John"
numbers = [1, 2, 3, 4, 5]
ages = {"John": 30, "Mary": 25}

2.3 运算符与表达式

运算符对比

  • 算术运算符:大部分相同(+, -, *, /)
  • Python中/总是返回浮点数,//用于整数除法
  • Python有**幂运算符,JAVA需要使用Math.pow()
  • Python支持链式比较(a < b < c)

示例对比

// JAVA运算符示例
int a = 10;
int b = 3;
double c = (double)a / b;  // 3.3333...
int d = a / b;             // 3
int e = (int)Math.pow(a, 2); // 100
boolean result = (a > 5 && a < 15); // true
# Python运算符示例
a = 10
b = 3
c = a / b    # 3.3333...
d = a // b   # 3
e = a ** 2   # 100
result = 5 < a < 15  # True

2.4 控制流结构

条件语句对比

// JAVA条件语句
if (x > 0) {
    System.out.println("Positive");
} else if (x < 0) {
    System.out.println("Negative");
} else {
    System.out.println("Zero");
}

// 三元运算符
String status = (age >= 18) ? "Adult" : "Minor";
# Python条件语句
if x > 0:
    print("Positive")
elif x < 0:
    print("Negative")
else:
    print("Zero")

# 条件表达式(Python的三元运算符)
status = "Adult" if age >= 18 else "Minor"

循环结构对比

// JAVA循环
// for循环
for (int i = 0; i < 10; i++) {
    System.out.println(i);
}

// 增强for循环(foreach)
for (String name : names) {
    System.out.println(name);
}

// while循环
int i = 0;
while (i < 10) {
    System.out.println(i);
    i++;
}
# Python循环
# for循环(使用range)
for i in range(10):
    print(i)

# for循环(迭代集合)
for name in names:
    print(name)

# while循环
i = 0
while i < 10:
    print(i)
    i += 1

特殊控制流

// JAVA中的break和continue
for (int i = 0; i < 10; i++) {
    if (i == 5) break;    // 跳出循环
    if (i % 2 == 0) continue;  // 跳过当前迭代
    System.out.println(i);
}

// JAVA中的异常处理
try {
    int result = divide(10, 0);
} catch (ArithmeticException e) {
    System.out.println("Division by zero");
} finally {
    System.out.println("Always executed");
}
# Python中的break和continue
for i in range(10):
    if i == 5:
        break    # 跳出循环
    if i % 2 == 0:
        continue  # 跳过当前迭代
    print(i)

# Python中的异常处理
try:
    result = divide(10, 0)
except ZeroDivisionError:
    print("Division by zero")
finally:
    print("Always executed")

2.5 函数与方法

函数定义对比

// JAVA方法
public static int add(int a, int b) {
    return a + b;
}

// 可变参数
public static int sum(int... numbers) {
    int total = 0;
    for (int num : numbers) {
        total += num;
    }
    return total;
}
# Python函数
def add(a, b):
    return a + b

# 可变参数
def sum(*numbers):
    total = 0
    for num in numbers:
        total += num
    return total

默认参数与命名参数

// JAVA中的默认参数(通过方法重载实现)
public static int multiply(int a, int b) {
    return a * b;
}

public static int multiply(int a) {
    return multiply(a, 1);  // 默认b=1
}

// JAVA不直接支持命名参数,但可以通过Builder模式或Map实现
# Python中的默认参数
def multiply(a, b=1):
    return a * b

# 调用方式
result1 = multiply(5)      # 返回5
result2 = multiply(5, 2)   # 返回10

# Python中的命名参数
def create_person(name, age, city="Unknown"):
    return {"name": name, "age": age, "city": city}

# 调用方式
person1 = create_person("John", 30)
person2 = create_person("Mary", 25, city="New York")
person3 = create_person(age=40, name="Bob")  # 参数顺序可变

Lambda表达式对比

// JAVA Lambda表达式(Java 8+)
Function<Integer, Integer> square = x -> x * x;
int result = square.apply(5);  // 返回25

// 使用Lambda排序
Collections.sort(names, (a, b) -> a.compareTo(b));
# Python Lambda表达式
square = lambda x: x * x
result = square(5)  # 返回25

# 使用Lambda排序
names.sort(key=lambda x: x.lower())

3. Python数据结构与JAVA对比

3.1 列表与数组

JAVA数组与ArrayList

  • 数组大小固定,类型固定
  • ArrayList大小可变,但类型仍然固定

Python列表

  • 大小可变
  • 可以存储不同类型的元素
  • 提供丰富的内置方法

对比示例

// JAVA数组
int[] numbers = {1, 2, 3, 4, 5};
System.out.println(numbers[0]);  // 访问元素

// JAVA ArrayList
ArrayList<Integer> list = new ArrayList<>();
list.add(1);
list.add(2);
list.add(3);
list.remove(0);  // 移除第一个元素
System.out.println(list.size());  // 获取大小
# Python列表
numbers = [1, 2, 3, 4, 5]
print(numbers[0])  # 访问元素

# 列表操作
numbers.append(6)  # 添加元素
numbers.pop(0)     # 移除第一个元素
print(len(numbers))  # 获取大小

# 列表推导式(Python特有)
squares = [x**2 for x in range(10)]
even_numbers = [x for x in range(20) if x % 2 == 0]

3.2 字典与映射

JAVA Map

  • 需要指定键和值的类型
  • 常用实现有HashMap, TreeMap等

Python字典

  • 键值对集合,键必须是不可变类型
  • 动态类型,无需预先声明类型
  • 提供简洁的创建和访问语法

对比示例

// JAVA HashMap
Map<String, Integer> scores = new HashMap<>();
scores.put("Alice", 95);
scores.put("Bob", 85);
scores.put("Charlie", 90);

// 访问和检查
if (scores.containsKey("Alice")) {
    System.out.println(scores.get("Alice"));
}

// 遍历
for (Map.Entry<String, Integer> entry : scores.entrySet()) {
    System.out.println(entry.getKey() + ": " + entry.getValue());
}
# Python字典
scores = {"Alice": 95, "Bob": 85, "Charlie": 90}

# 访问和检查
if "Alice" in scores:
    print(scores["Alice"])

# 遍历
for name, score in scores.items():
    print(f"{name}: {score}")

# 字典推导式
square_dict = {x: x**2 for x in range(5)}

3.3 元组与集合

元组:Python中的不可变序列,JAVA中没有直接对应物

# Python元组
point = (10, 20)
name_age = ("John", 30)

# 元组解包
x, y = point
name, age = name_age

# 元组作为字典键
locations = {
    (0, 0): "Origin",
    (10, 20): "Point A",
    (50, 60): "Point B"
}

集合对比

// JAVA Set
Set<String> fruits = new HashSet<>();
fruits.add("Apple");
fruits.add("Banana");
fruits.add("Apple");  // 重复元素不会添加

// 集合操作
Set<String> moreFruits = new HashSet<>();
moreFruits.add("Orange");
moreFruits.add("Banana");

// 并集
Set<String> union = new HashSet<>(fruits);
union.addAll(moreFruits);

// 交集
Set<String> intersection = new HashSet<>(fruits);
intersection.retainAll(moreFruits);
# Python集合
fruits = {"Apple", "Banana", "Apple"}  # 重复元素会被自动移除

# 集合操作
more_fruits = {"Orange", "Banana"}

# 并集
union = fruits | more_fruits  # 或 fruits.union(more_fruits)

# 交集
intersection = fruits & more_fruits  # 或 fruits.intersection(more_fruits)

# 集合推导式
vowels = {char for char in "hello world" if char in "aeiou"}

3.4 字符串处理

字符串对比

// JAVA字符串
String text = "Hello, World!";
String sub = text.substring(0, 5);  // "Hello"
String upper = text.toUpperCase();
String[] parts = text.split(", ");

// 字符串连接
String name = "John";
String greeting = "Hello, " + name + "!";
// 或使用String.format (类似Python的%格式化)
String greeting2 = String.format("Hello, %s!", name);
// Java 15+支持文本块
String html = """
              <html>
                <body>
                  <h1>Hello, World!</h1>
                </body>
              </html>
              """;
# Python字符串
text = "Hello, World!"
sub = text[:5]  # "Hello"
upper = text.upper()
parts = text.split(", ")

# 字符串连接
name = "John"
greeting = "Hello, " + name + "!"
# 使用f-strings (Python 3.6+)
greeting2 = f"Hello, {name}!"
# 多行字符串
html = """
<html>
  <body>
    <h1>Hello, World!</h1>
  </body>
</html>
"""

4. Python面向对象编程

4.1 类与对象

类定义对比

// JAVA类
public class Person {
    // 实例变量
    private String name;
    private int age;
    
    // 构造函数
    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }
    
    // Getter和Setter
    public String getName() {
        return name;
    }
    
    public void setName(String name) {
        this.name = name;
    }
    
    public int getAge() {
        return age;
    }
    
    public void setAge(int age) {
        this.age = age;
    }
    
    // 实例方法
    public void greet() {
        System.out.println("Hello, my name is " + name);
    }
}

// 使用类
Person person = new Person("John", 30);
person.greet();
System.out.println(person.getName());
# Python类
class Person:
    # 构造函数
    def __init__(self, name, age):
        self.name = name  # Python默认公开属性
        self.age = age
    
    # 实例方法
    def greet(self):
        print(f"Hello, my name is {self.name}")

# 使用类
person = Person("John", 30)
person.greet()
print(person.name)  # 直接访问属性

4.2 继承与多态

继承对比

// JAVA继承
public class Employee extends Person {
    private String company;
    private double salary;
    
    public Employee(String name, int age, String company, double salary) {
        super(name, age);  // 调用父类构造函数
        this.company = company;
        this.salary = salary;
    }
    
    // 覆盖父类方法
    @Override
    public void greet() {
        System.out.println("Hello, I'm " + getName() + " from " + company);
    }
    
    // 新方法
    public void work() {
        System.out.println("Working at " + company);
    }
}
# Python继承
class Employee(Person):
    def __init__(self, name, age, company, salary):
        super().__init__(name, age)  # 调用父类构造函数
        self.company = company
        self.salary = salary
    
    # 覆盖父类方法
    def greet(self):
        print(f"Hello, I'm {self.name} from {self.company}")
    
    # 新方法
    def work(self):
        print(f"Working at {self.company}")

多态对比

// JAVA多态
public void displayGreeting(Person person) {
    person.greet();  // 调用的方法取决于实际对象类型
}

Person person = new Person("John", 30);
Employee employee = new Employee("Jane", 28, "ABC Corp", 50000);

displayGreeting(person);    // 输出: Hello, my name is John
displayGreeting(employee);  // 输出: Hello, I'm Jane from ABC Corp
# Python多态(鸭子类型)
def display_greeting(person):
    person.greet()  # 只要对象有greet方法就可以调用

person = Person("John", 30)
employee = Employee("Jane", 28, "ABC Corp", 50000)

display_greeting(person)    # 输出: Hello, my name is John
display_greeting(employee)  # 输出: Hello, I'm Jane from ABC Corp

4.3 封装与访问控制

JAVA访问控制

  • private:仅类内部可访问
  • protected:类内部和子类可访问
  • public:任何地方可访问
  • package-private(默认):同包内可访问

Python访问控制

  • 约定使用单下划线前缀(_name)表示protected
  • 约定使用双下划线前缀(__name)表示private(实际通过名称修饰实现)
  • 无显式访问控制关键字
// JAVA封装
public class Account {
    private double balance;  // 私有变量
    
    public void deposit(double amount) {
        if (amount > 0) {
            balance += amount;
        }
    }
    
    public double getBalance() {
        return balance;
    }
}
# Python封装
class Account:
    def __init__(self):
        self.__balance = 0  # 名称修饰为_Account__balance
    
    def deposit(self, amount):
        if amount > 0:
            self.__balance += amount
    
    def get_balance(self):
        return self.__balance

4.4 特殊方法与运算符重载

Python允许通过特殊方法(双下划线方法,也称为魔术方法)自定义对象行为:

class Vector:
    def __init__(self, x, y):
        self.x = x
        self.y = y
    
    # 字符串表示
    def __str__(self):
        return f"Vector({self.x}, {self.y})"
    
    # 加法运算符重载
    def __add__(self, other):
        return Vector(self.x + other.x, self.y + other.y)
    
    # 等于运算符重载
    def __eq__(self, other):
        return self.x == other.x and self.y == other.y
    
    # 长度(用于len()函数)
    def __len__(self):
        return int((self.x**2 + self.y**2)**0.5)

# 使用
v1 = Vector(1, 2)
v2 = Vector(3, 4)
v3 = v1 + v2  # 调用__add__方法
print(v3)      # 调用__str__方法
print(v1 == v2)  # 调用__eq__方法
print(len(v1))   # 调用__len__方法

JAVA中需要显式实现接口或覆盖方法:

public class Vector {
    private double x;
    private double y;
    
    public Vector(double x, double y) {
        this.x = x;
        this.y = y;
    }
    
    // 字符串表示
    @Override
    public String toString() {
        return "Vector(" + x + ", " + y + ")";
    }
    
    // 等于运算符
    @Override
    public boolean equals(Object obj) {
        if (this == obj) return true;
        if (obj == null || getClass() != obj.getClass()) return false;
        Vector vector = (Vector) obj;
        return Double.compare(vector.x, x) == 0 && Double.compare(vector.y, y) == 0;
    }
    
    // 加法(不是运算符重载,而是普通方法)
    public Vector add(Vector other) {
        return new Vector(this.x + other.x, this.y + other.y);
    }
    
    // 获取长度
    public int length() {
        return (int) Math.sqrt(x*x + y*y);
    }
}

5. Python生态系统和包管理

5.1 Python解释器与环境

Python解释器

  • CPython:标准实现,C语言编写
  • PyPy:JIT编译,提高性能
  • Jython:运行在JVM上
  • IronPython:运行在.NET上

虚拟环境

  • venv:Python标准库提供的虚拟环境工具
  • conda:Anaconda提供的环境和包管理工具
  • virtualenv:第三方虚拟环境工具

创建和使用虚拟环境

# 创建虚拟环境
python -m venv myenv

# 激活虚拟环境
# Windows
myenv\Scripts\activate
# Unix/MacOS
source myenv/bin/activate

# 安装包
pip install numpy pandas

# 查看已安装的包
pip list

# 导出依赖
pip freeze > requirements.txt

# 从依赖文件安装
pip install -r requirements.txt

5.2 包管理与依赖

JAVA依赖管理

  • Maven:使用pom.xml定义依赖
  • Gradle:使用build.gradle定义依赖

Python依赖管理

  • pip:Python包安装工具
  • requirements.txt:列出项目依赖
  • setup.py:定义Python包
  • pyproject.toml:现代Python项目配置(Poetry, Flit等)

对比示例

<!-- JAVA Maven pom.xml -->
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <version>2.5.0</version>
    </dependency>
</dependencies>
# Python requirements.txt
numpy==1.21.0
pandas>=1.3.0
matplotlib~=3.4.0
# Python setup.py
from setuptools import setup, find_packages

setup(
    name="mypackage",
    version="0.1",
    packages=find_packages(),
    install_requires=[
        "numpy>=1.21.0",
        "pandas>=1.3.0",
    ],
)
# pyproject.toml (Poetry)
[tool.poetry]
name = "mypackage"
version = "0.1.0"
description = "My Python package"

[tool.poetry.dependencies]
python = "^3.8"
numpy = "^1.21.0"
pandas = "^1.3.0"

5.3 常用Python库

数据科学和机器学习

  • NumPy:科学计算基础库,提供多维数组支持
  • Pandas:数据分析和操作库
  • Matplotlib/Seaborn:数据可视化
  • SciPy:科学计算
  • Scikit-learn:机器学习算法

深度学习

  • TensorFlow:Google开发的深度学习框架
  • PyTorch:Facebook开发的深度学习框架
  • Keras:高级神经网络API

大模型开发

  • Hugging Face Transformers:预训练模型库
  • LangChain:大型语言模型应用开发框架
  • NLTK/SpaCy:自然语言处理

Web开发

  • Flask:轻量级Web框架
  • Django:全功能Web框架
  • FastAPI:现代、高性能的API框架

数据库访问

  • SQLAlchemy:SQL工具包和ORM
  • psycopg2:PostgreSQL适配器
  • pymongo:MongoDB客户端

5.4 模块和包结构

JAVA包结构

src/
  ├── main/
  │   ├── java/
  │   │   └── com/
  │   │       └── example/
  │   │           ├── Main.java
  │   │           ├── model/
  │   │           ├── service/
  │   │           └── util/
  │   └── resources/
  └── test/
      └── java/

Python包结构

mypackage/
  ├── __init__.py
  ├── main.py
  ├── models/
  │   ├── __init__.py
  │   └── user.py
  ├── services/
  │   ├── __init__.py
  │   └── auth.py
  └── utils/
      ├── __init__.py
      └── helpers.py

Python模块导入

# 导入整个模块
import math
print(math.sqrt(16))

# 导入特定函数
from math import sqrt
print(sqrt(16))

# 导入并重命名
import numpy as np
print(np.array([1, 2, 3]))

# 导入自定义模块
from mypackage.utils.helpers import format_date

6. JAVA开发者的Python学习策略

6.1 利用已有知识

相似概念

  • 面向对象编程
  • 基本控制流结构
  • 异常处理
  • 集合操作
  • 函数式编程(Java 8+)

学习建议

  • 关注语法差异而非概念差异
  • 使用类比方法理解Python特性
  • 从简单脚本开始,逐步过渡到复杂应用
  • 利用IDE的代码补全和文档功能

6.2 重点学习内容

语法特性

  • 动态类型系统
  • 缩进和代码块
  • 列表/字典推导式
  • 解包赋值
  • 装饰器

编程范式

  • 函数式编程特性
  • 生成器和迭代器
  • 上下文管理器(with语句)
  • 元编程

生态系统

  • 虚拟环境和包管理
  • 科学计算库(NumPy, Pandas)
  • 机器学习框架(PyTorch, TensorFlow)
  • Jupyter Notebook交互式开发

6.3 常见陷阱和误区

类型相关

  • Python中的变量是标签,不是容器
  • 可变默认参数陷阱
  • 引用vs复制
# 可变默认参数陷阱
def add_item(item, items=[]):  # 错误:默认参数在函数定义时计算一次
    items.append(item)
    return items

print(add_item(1))  # [1]
print(add_item(2))  # [1, 2] 而不是预期的 [2]

# 正确做法
def add_item_correct(item, items=None):
    if items is None:
        items = []
    items.append(item)
    return items

作用域

  • Python的LEGB规则(Local, Enclosing, Global, Built-in)
  • 闭包中的变量访问
# 闭包中的变量访问
def counter():
    count = 0
    
    def increment():
        nonlocal count  # 声明使用外部作用域的变量
        count += 1
        return count
    
    return increment

c = counter()
print(c())  # 1
print(c())  # 2

性能

  • Python的GIL(全局解释器锁)限制
  • 使用适当的数据结构和算法
  • 计算密集型任务考虑使用NumPy或Cython

6.4 实用学习资源

在线课程

  • “Python for Java Developers”(Pluralsight)
  • “Python for Programmers”(Coursera)
  • “Python数据科学手册”(Jake VanderPlas)

书籍

  • 《Python编程:从入门到实践》
  • 《流畅的Python》
  • 《Effective Python》
  • 《Python for Data Analysis》

实践平台

  • LeetCode(同时支持Java和Python)
  • Kaggle(数据科学和机器学习)
  • GitHub上的开源项目

7. 实践练习

练习1:基本语法转换

将以下JAVA代码转换为等效的Python代码:

public class Calculator {
    public static int factorial(int n) {
        if (n <= 1) return 1;
        return n * factorial(n - 1);
    }
    
    public static void main(String[] args) {
        int[] numbers = {1, 2, 3, 4, 5};
        int sum = 0;
        
        for (int num : numbers) {
            sum += num;
        }
        
        System.out.println("Sum: " + sum);
        System.out.println("Factorial of 5: " + factorial(5));
    }
}

练习2:数据处理

使用Python的列表和字典实现以下功能:

  1. 创建一个包含10个随机数的列表
  2. 计算列表中所有偶数的平方和
  3. 创建一个字典,键为列表中的数字,值为其出现次数

练习3:面向对象编程

设计一个简单的银行账户系统,包括:

  1. 账户类(Account):包含账号、余额和交易历史
  2. 储蓄账户类(SavingsAccount):继承Account,添加利率属性和计算利息方法
  3. 支票账户类(CheckingAccount):继承Account,添加透支额度属性

8. 总结与反思

  • Python和JAVA都是强大的通用编程语言,但有不同的设计理念和应用场景
  • Python的动态类型和简洁语法使其成为数据科学和AI/ML领域的首选语言
  • JAVA开发者可以利用已有的编程概念快速学习Python
  • 理解两种语言的差异和各自优势,有助于在适当场景选择合适的工具
  • 大模型开发主要使用Python生态系统,包括NumPy, PyTorch, Hugging Face等库

9. 预习与延伸阅读

预习内容

  • NumPy基础:数组操作、广播机制、向量化计算
  • Pandas基础:Series和DataFrame、数据读写、数据清洗
  • 数据可视化:Matplotlib和Seaborn基础

延伸阅读

  1. Jake VanderPlas,《Python数据科学手册》
  2. Wes McKinney,《利用Python进行数据分析》
  3. Luciano Ramalho,《流畅的Python》
  4. Brett Slatkin,《Effective Python》

10. 明日预告

明天我们将开始第二阶段的学习,重点关注数据科学和机器学习库,包括NumPy和Pandas基础、数据处理和特征工程,以及使用Matplotlib和Seaborn进行数据可视化。这些工具是大模型开发中数据准备和分析的基础。

Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐