2. Python要点

1. Python语言

1.1 Python语言的基本概念

  1. 吉多 龟叔 一个人发明的语言 他使用C语言时觉得代码太多了,觉得不爽,就想发明一种语言增加效率。于是他1989年开发出Python。
  2. 同时期的Java语言也在1995年面世了,它是sun公司维护的。在这里插入图片描述

1.2 根据转换的时机不同

  1. 编译型语言: C语言为代表,xx(源码)>编译>yy(编译后的机器码)
    优点是 执行速度快,缺点是 跨平台性比较差。
  2. 解释性语言: Python语言为代表,xx(源码)>解释器>解释执行
    优点 执行速度快 跨平台性比较好

1.3 Python语言特色

  1. 简单易学
  2. 自由且开发 pip install xxx
  3. 开平台及可嵌入性
  4. “内置电池”,大量的标准库和第三方库
  5. 社区活跃,贡献者多,互帮互助
  6. 开源语言,发展动力巨大

1.4 Python应用方向

  1. 常规软件开发
  2. 科学计算
  3. 自动化运维
  4. 云计算
  5. WEB开发
  6. 网络爬虫
  7. 数据分析
  8. 人工智能

1.5 Python之禅

输入代码 import this
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!

2. 搭建开发环境

2.1 Python的解释器

  1. 环境搭建就是安装Python的解释器
  2. Python的解释器分类:
    CPython(官⽅版本) ⽤c语⾔编写的Python解释器
    PyPy ⽤Python语⾔编写的Python解释器
    JPython ⽤Java编写的Python解释器

2.2搭建Python环境

  1. 下载安装包,https://www.python.org/
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
  2. 安装成功后,win键 + R --> CMD --> 回⻋ --> 输⼊Python
  3. 命令⾏结构
  4. Python 3. 7. 3 … —> 版本
  5. Type “help”,“copyright”…—> 版权声明
  6. 命令提示符 (在后⾯可以直接输⼊指令)
    在这里插入图片描述

2.3 pip工具的使用

  1. pip介绍
    Python官⽅的PyPi仓库为我们提供了⼀个统⼀的代码托管仓库,所有的第三⽅库,甚⾄你⾃⼰写的开源模块,都可以发布到这⾥,让全世界的⼈分享下载 。
  2. pip使用
    在命令行下,输⼊pip,回⻋可以看到帮助说明:
    在这里插入图片描述
  3. 查看pip版本
    在这里插入图片描述
  4. 普通安装 与 指定版本安装 与 卸载 列出所有的包 及信息
    普通安装
    指定版本安装
    卸载
    列出所有的包
    显示 包的信息
  5. 将已经安装的库列表保存到⽂本⽂件中
    pip freeze > D:\桌⾯\install.txt
    在这里插入图片描述
  6. 使用wheel文件安装
    除了使⽤上⾯的⽅式联⽹进⾏安装外,还可以将安装包也就是wheel格式的⽂件,下载到本地,然后使⽤pip进⾏安装。⽐如我在PYPI上提前下载的pillow库的wheel⽂件,后缀名为whl。
    可以使⽤pip install pillow-4.2xxxxxxx.whl的⽅式离线进⾏安装
    在这里插入图片描述
  7. 换源安装
    ⾖瓣 :http://pypi.douban.com/simple/
    阿⾥ :http://mirrors.aliyun.com/pypi/simple/
    中国科学技术⼤学:http://pypi.mirrors.ustc.edu.cn/simple
    清华:https://pypi.tuna.tsinghua.edu.cn/simple
    例如:pip install SomePackage -i http://pypi.douban.com/simple

2.4 Python的第⼀个程序

  1. 可以在交互模式实现
  2. 可以⽤Python⾃带的idle
  3. 可以⽤⾼级开发⼯具如 : PyCharm

3. PyCharm的安装和配置

3.1 PyCharm的安装

在这里插入图片描述
由于笔者安装的专业版本好不容易激活的,在这就不卸载重装了,借用一下老师的图片,感谢老师
在这里插入图片描述在这里插入图片描述在这里插入图片描述在这里插入图片描述
如果有32位系统的可以打勾32位的

3.2 PyCharm的简单配置

  1. 主题修改 File–settings–apperance–theme

  2. 代码字体修改 File–settings–Editor-Font

  3. 关闭更新 File–settings—apperance—System Settings —
    Updates — Automatically check updates for 取消打钩

  4. 快捷键修改 File–settings—apperance-- Keymap 选择⾃⼰习惯的
    快捷键⽅式

  5. ⾃动导包 File–settings—apperance–General —Auto Import
    打钩

  6. 进制打开上次的⼯程 File–settings—apperance—System
    Settings —Reopen last project startup

  7. 修改新建⽂件⽂件头 File–settings–Editor—Code Style — File
    and Code Templates — Python Script

      #!/usr/bin/env python
      -*- coding: utf-8 -*-
      @Time   : ${DATE} ${TIME}
      @Author  : Jimth Li
      @File   : ${NAME}.py
      @Software: ${PRODUCT_NAME}
    
  8. 修改字体编码 File–settings–Editor—Code Style — File
    Encoding — Project Encoding

4. 迈进程序的大门

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值