02-Python要点

02-Python要点

  • 1、Python语言
    • 1.1、Python语言的基本概念

    • 1.2、Python的特点

      • 简单
      • 易于学习
      • 自由且开放
      • 跨平台
      • 可嵌入性(在别的语言中嵌入Python)
      • 丰富的库
    • 1.3、Python的发展
      <img src = 'https://ftp.bmp.ovh/imgs/2020/08/96b50769123b72ef.png' />

    • 1.4、Python的应用

      • 常规软件开发
      • 科学计算
      • 自动化运维
      • 自动化测试
      • WEB开发
      • 网络爬虫
      • 数据分析
      • 人工智能
    • 1.4、Python给咱的寄语

      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的解释器
      • 环境搭建就是安装Python的解释器
      • Python的解释器分类:
      • CPython(官方我们用的就是这个版本) 用c语言编写的Python解释器
      • PyPy 用Python语言编写的Python解释器
      • JPython 用Java编写的Python解释器
    • 2.2、搭建Python环境
      • 下载安装包(官网
        <img src = 'https://ftp.bmp.ovh/imgs/2020/08/e629b312b10c1fca.png' />

      • 安装完成
        <img src = 'https://ftp.bmp.ovh/imgs/2020/08/d2017ce020153cf2.png' />

      • 2.3、pip工具的使用

        • pip介绍
          pip 是一个现代的,通用的 Python 包管理工具。提供了对 Python 包的查找、下载、安装、卸载的功能。

        python有两个著名的包管理工具easy_install和pip。在python 2中easy_install是默认安装的,而pip需要我们手动安装。随着Python版本的提高,easy_install已经逐渐被淘汰,但是一些比较老的第三方库,在现在仍然只能通过easy_install进行安装。目前,pip已经成为主流的安装工具,自Python 2 >=2.7.9或者Python 3.4以后默认都安装有pip

        • pip使用
          • 在命令行下,输入pip,回车可以看到帮助说明:
            <img src = 'https://ftp.bmp.ovh/imgs/2020/08/a90e600f2793a3d9.png' />
        • 查看pip版本
        pip -V
        pip --version
        

        <img src = 'https://ftp.bmp.ovh/imgs/2020/08/1802e371dfab0845.png' />

        • 普通安装
        pip install requests
        
        • 指定版本安装
        pip install robotframework==2.8.7
        
        • 卸载已经安装的库
        pip uninstall requests
        
        pip install SomePackage             
        pip install SomePackage==1.0.5       # 指定版本
        pip install 'SomePackage>=1.0.6'     # 最小版本
        

        升级指定的包,通过使用==, >=, <=, >, < 来指定一个版本号。

        • 列出已经安装的库
        pip list
        
        在这里插入图片描述
        • 显示所安装包的信息
        pip show package
        
      • 2.5、Python的第一个程序

        • 可以在交互模式实现
          [图片上传失败...(image-89bcf9-1598543003637)]
        • 可以用Python自带的idle


          在这里插入图片描述
        • 可以用高级开发工具如 : PyCharm


          在这里插入图片描述
  • 3、PyCharm的安装
    官网
    在这里插入图片描述
    • 安装完成后打开,一般会新建项目:


      在这里插入图片描述
      • New environment using就是使用虚拟环境。
      • Exiting interpreter就是使用已经存在的环境,全局的。
      • 创建之后就可以尝试写自己的第一个程序了。
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。