跳到主要内容

python 基础

环境配置

windows

安装步骤
  • 下载安装包,
  • 勾选 add python to path
检查是否安装成功
  • 打开系统终端;
  • 输入代码 python
  • 如出现下图,则安装成功,反之安装不成功。
PS C:\Users\KXH> python
Python 3.9.9 (tags/v3.9.9:ccb0e6a, Nov 15 2021, 18:08:50) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

linux

debian
sudo apt install python3 -y
sudo apt install python3-pip -y

IDE/文本编辑器

  • pycharm;
  • vs code;

Python terminal

  • 打开任意终端,
  • 键入 python
  • 进入 python 终端,
  • 使用 quit()/exit() 退出。

常用命令

# linux python 替换为 python3
# 查看 python 版本
python --version

运行 python 文件

文本编辑器/IDE

# 创建文件
# 输入代码
print("Hello Python world!")
  • 运行代码。

terminal

# 打开 terminal
# 输入代码
PS D:\kxh\test\python\python_crash_course\chapter_01> python hello_world.py
hello python world!

Python terminal

  • 打开 Python terminal;
  • 输入代码;