Python安装
https://www.python.org/downloads/windows/
PyCharm安装
- Pycharm 配置 pip源切换
- 豆瓣:Simple Index
- 清华:Simple Index
- 阿里云:Simple Index
创建项目
虚拟环境
安装libray
pip config set global.trusted-host mirrors.aliyun.com
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple
第一个脚本
from selenium import webdriver
driver = webdriver.Edge()
driver.get("https://ceshiren.com/t/topic/25737")
chatgpt关键字
实现一套课程管理系统,只需要管理ppt即可,课程管理系统使用python编写,使用数据库存储,使用bootstrap做前端
debug
- 断点
- 单步执行
- 单步进入 step into
trace
PYTHONPATH=. python -m trace -t --ignore-module=_bootstrap,_bootstrap_external,__init__ course_manager/student.py
pytest
unittest
pytest 推荐
https://docs.pytest.org/
pip install pytest
目录结构
- src 存放代码
- tests 存放测试用例
- README.md
- setup.py
练习4
用python代码实现
- name: string
- email: string
+ get_info(): string
}
class Student {
- courses: List<Course>
+ add_course(course: Course)
+ remove_course(course: Course)
+ get_courses(): List<Course>
+ get_info(): string
}
class Teacher {
- courses: List<Course>
+ add_course(course: Course)
+ remove_course(course: Course)
+ get_courses(): List<Course>
+ get_info(): string
}
class Admin {
+ add_student(student: Student)
+ remove_student(student: Student)
+ add_teacher(teacher: Teacher)
+ remove_teacher(teacher: Teacher)
+ add_course(course: Course)
+ remove_course(course: Course)
}
class Course {
- name: string
- teacher: Teacher
- students: List<Student>
+ get_info(): string
}
Student *-- Course
Teacher *-- Course
Course "1"--o "1" Teacher
Course "1"--o "1..*" Student
Admin ..> Person
Person <|-- Student
Person <|-- Teacher
Person <|-- Admin
练习5
设计一个课程管理系统,学校拥有课程
课程里有名字,ppt和视频地址
老师与管理员可以添加课程到学校
学生可以从学校获取课程