Python 第二节课

这篇博客介绍了Python的基础知识,包括Python的应用方向,如后端开发、自动化和数据分析。讲解了Python之禅,强调代码的优美、简洁和可读性。详细阐述了Python环境搭建,包括安装Python、设置环境变量以及pip的使用。此外,还提到了wheel文件的安装和代码编辑器PyCharm的配置。最后,给出了Python作业,涉及手动安装Python、配置环境和使用不同工具输出Hello World。
摘要由CSDN通过智能技术生成

Python介绍

Python 应用方向

  • 后端 (web)
  • 自动化 (Office Automation、Test)
  • 数据()

Python 之禅

  • 在确保安装好python的情况下:
  1. windows + R
  2. 输入python进入python交互环境
  3. import this
    Beautiful is better than ugly. --> 优美胜于丑陋
    Explicit is better than implicit. --> 明了胜于晦涩
    Simple is better than complex --> 简洁胜于复杂
    Flat is better than nested. --> 扁平胜于嵌套
    Sparse is better than dense. --> 间隔胜于紧凑
    Readability counts. --> 可读性很重要

编译器与解释器

  • 区别
    • 编译器:先整体编译再执行
    • 解释器:边解释边执行
  • Python接收器种类
    • CPython
    • Ipython
    • PyPy
    • Jython

Python环境搭建

  • Python下载
  1. CLICK python 官网:http://www.python.org/
  2. CLICK Download
  3. CLICK Windows / Mac
  4. Ctrl + F Search Python 3.6.4
  5. Download Windows x86-64 executable installer
  • Python 安装
  1. Open Install File
  2. CHOOSE Customize installation(CLICK Add Python 3.6 to PATH
  3. ALL CHOOSE Optional Features
  4. MUST CHOOSE Add Python to environment variables
  5. CHOOSE LOCATION 除C盘外的其他地址记得安装地址
  6. Install
  • 添加环境变量
  1. Open My Desktop
  2. CLICK 鼠标右键 --> 属性
  3. CLICK 高级系统设置
  4. CLICK 环境变量
  5. CHOOSE 系统变量 --> Path --> 编辑
  6. CLICK 新建 --> COPY & PASTE “Python 存储路径”
  7. CLICK 新建 --> COPY & PASTE “Python Scripts 存储路径”
  8. 确定保存,以及重启 dos 命令行

pip的安装与使用

  • pypi 仓库
    • Python提供许多第三方库或模块,而PyPi就是一个统一的代码托管仓库。
  • pip 介绍
    • 在Python中,使用pip对pypi仓库中的第三方库进行安装、卸载、更新等操作命令。
      -pip的基础使用
    • 普通安装
      • 进入DOS命令行
      • 进入logic(系统环境) (python环境中不能install pip)
      • 输入pip install pygame
      • Successfully installed pygame
    • 指定版本安装
      • pip install pygame==2.2.0
    • 卸载已安装
      • pip uninstall pygame
    • 列出已安装
      • pip list
      • pip freeze
    • 导出所有pip文件
      • pip freeze > D:\ requirement.txt 在D盘创建一个requirement的文本档案
    • 安装导出的pip文件
      • pip install -r D:\ requirement.txt

wheel 文件安装

    • wheel 安装介绍与实现
    • 介绍:在脱网前,将wheel格式文件下载到本地,然后使用pip进行安装
    • 实现
      • pip install wheel 安装 wheel 这个库
      • 打开网址 https://www.lfd.uci.edu/~gohlke/pythonlibs/
        • Ctrl + F pygame
        • CHOOSE pygame‑1.9.6‑cp36‑cp36m‑win_amd64.whl
        • DOWNLOAD
        • 将安装包迁移到python路径
        • 在dos命令环境输入pip install + pygame wheel 文件路径 + 安装包名称

开启搬砖之旅 – 代码编辑器

  • PyCharm编辑器介绍及下载
    • PyCharm 安装地址https://www.jetbrains.com/pycharm/download/#section=windows
    • CHOOSE Community
    • DOWNLOAD
    • 安装在C盘
  • PyCharm的基础使用
    • 配置Python解释器
      • Open File --> Settings --> Project --> Project Interpreter
      • 界面选择SETTING按钮 --> ADD
      • 在Project Interpreter中添加至Python路径下的python.exe文件
      • ALL OK

Python 作业

在这里插入图片描述

手动安装Python

在这里插入图片描述

手动配置python系统环境

在这里插入图片描述

pip whl 临时换源安装pygame

  • pip 安装pygame
    在这里插入图片描述
    在这里插入图片描述
  • pip卸载pygame
    在这里插入图片描述

python idle、ipython、pycharm输出hello world

  • python idle 输出 hello world
    在这里插入图片描述
  • ipython 输出 hello world
    在这里插入图片描述
  • PyCharm 输出 hello world
    在这里插入图片描述
  • 配置Python解释器
    在这里插入图片描述
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值