Files
DailyChallenge_ProgrammingD…/Day_1/README.md
T
2026-08-22 01:09:18 +08:00

45 lines
2.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Day_1 · 配置 Python 环境,运行第一个程序
> 预计耗时:20~30 分钟
> 电脑上没有 Python 一切都无从谈起。今天的目标:装好它,并用**两种方式**运行同一个程序。
## 今日知识点
- 什么是 Python 解释器(你写的代码靠它执行)
- 安装时务必勾选 **Add Python to PATH**(否则命令行找不到 python)
- 运行 `.py` 文件的两种方式:命令行 `python 文件名.py`、或 IDE(IDLE / VS Code)里点运行
## 先学(教程)
- 菜鸟教程(看"第一个Python程序"和"Python 环境搭建"两节):https://www.runoob.com/python3/python3-tutorial.html
- B站(黑马程序员,看最前面"软件下载安装、IDE 使用"几集即可):https://www.bilibili.com/video/BV1qW4y1a7fU/
## 任务(后做)
1. 下载安装 Python:https://www.python.org/downloads/ ,安装时**勾选 Add Python to PATH**
2. 打开命令行,运行 `python --version`,看到版本号(如 `Python 3.12.x`)即成功
3. 新建文件 `hello.py`(可以继续用 Day_0 你上传过的那份),内容是:
```python
print("Hello World")
```
4. **方式一(命令行)**:在 `hello.py` 所在目录打开命令行,运行 `python hello.py`,看到输出 `Hello World`
5. **方式二(IDE)**:安装 VS Code(https://code.visualstudio.com/ ,装完在扩展里搜 "Python" 安装),
用 VS Code 打开 `hello.py`,点右上角三角按钮运行,同样看到 `Hello World`
> 小贴士:命令行里任何一步报"不是内部或外部命令",八成是 PATH 没勾,重装一遍记得勾上。
## 完成标准
- [ ] `python --version` 有版本号输出
- [ ] 命令行 `python hello.py` 跑出 `Hello World`
- [ ] VS Code 里也能跑出 `Hello World`
**提交方式**:把命令行运行 `python hello.py` 的**截图**贴在当日工单的评论里。
## 参考解答(先做再看)
```python
print("Hello World")
```
就这一行。能跑出来,今天的目标就完成了。