zoukankan      html  css  js  c++  java
  • python安装与使用(Windows)

      日常使用PHP开发较多,但是有些地方PHP的语言的瓶颈就显露出来了,例如,同样是抓取一个网站的内容,使用PHP需要较为复杂的正则匹配,效率较为低下。python具有丰富的类库,拿过来直接可以使用,功能强大,飞一样的感觉。学习与使用python就变得尤为的重要

      安装

      在本地我安装的是最新的python版本3.7.0     ,有些人会纠结到底是使用python2还是python3呢,虽然两个版本相差的较多,但是基本的一些东西和思想是一致的。所以了解了这些,我们是不是可以不拘于表象而是直击要害  --》学习并掌握这门技术才是硬道理!!!

       我为什么选择使用python3而不是python2呢?我一直是喜爱追求新的东西,当然编程也不例外,就好像PHP出了7之后,开发自己项目的时候总是搭建一个最新的环境使用最新的PHP语法与特性。编程这个行业总是在不断更新迭代中,也是向着好的地方发展,我相信新的一定有一定的道理,一定有胜于之前的利器!!!废话不多说,Go

      从官网上选择下载适合自己电脑的python版本

        选择版本:https://www.python.org/downloads/release/python-370/  -》 Windows x86-64 web-based installer    下载安装即可(添加path路径)

      使用

        

      交互模式:

    python -V   // 查看版本
    

      

    python      //直接运行python命令即进入交互模式
    
    Ctrl+ d  或者 quit()   //退出
    

      

      

      PIP的安装:

        pip就像是centos中的yum,可以方便进行相关插件,模块的安装

    1)下载:  https://pypi.org/project/pip/#history

    2)解压到一个目录下,执行命令进行安装

    python setup.py install

    3)这个时候,就可以使用pip相关命令

    Usage:
      pip3 <command> [options]
    
    Commands:
      install                     Install packages.
      download                    Download packages.
      uninstall                   Uninstall packages.
      freeze                      Output installed packages in requirements format.
      list                        List installed packages.
      show                        Show information about installed packages.
      check                       Verify installed packages have compatible dependencies.
      config                      Manage local and global configuration.
      search                      Search PyPI for packages.
      wheel                       Build wheels from your requirements.
      hash                        Compute hashes of package archives.
      completion                  A helper command used for command completion.
      help                        Show help for commands.
    
    General Options:
      -h, --help                  Show help.
      --isolated                  Run pip in an isolated mode, ignoring environment variables and user
                                  configuration.
      -v, --verbose               Give more output. Option is additive, and can be used up to 3 times.
      -V, --version               Show version and exit.
      -q, --quiet                 Give less output. Option is additive, and can be used up to 3 times
                                  (corresponding to WARNING, ERROR, and CRITICAL logging levels).
      --log <path>                Path to a verbose appending log.
      --proxy <proxy>             Specify a proxy in the form [user:passwd@]proxy.server:port.
      --retries <retries>         Maximum number of retries each connection should attempt (default 5
                                  times).
      --timeout <sec>             Set the socket timeout (default 15 seconds).
      --exists-action <action>    Default action when a path already exists: (s)witch, (i)gnore, (w)ipe,
                                  (b)ackup, (a)bort).
      --trusted-host <hostname>   Mark this host as trusted, even though it does not have valid or any
                                  HTTPS.
      --cert <path>               Path to alternate CA bundle.
      --client-cert <path>        Path to SSL client certificate, a single file containing the private key
                                  and the certificate in PEM format.
      --cache-dir <dir>           Store the cache data in <dir>.
      --no-cache-dir              Disable the cache.
      --disable-pip-version-check
                                  Don't periodically check PyPI to determine whether a new version of pip
                                  is available for download. Implied with --no-index.
      --no-color                  Suppress colored output

         注意: 如果是安装了一个python的版本,那么pip和pip3都可以进行使用,效果是相同的,这个是因为为了使用不同python版本的时候的区分, 例如:默认pip指向python2, 那么pip3则指向python3

    4)常用命令

    #安装包
    pip  install package
    
    #升级包,可以使用-U或 --upgrade
    pip install -U package
    
    #卸载包
    pip uninstall package
    
    #列出已安装的包
    pip list
  • 相关阅读:
    正则表达式30分钟入门教程
    Python的神奇方法指南
    Python 2.7教程
    javaweb开发.常用的第三方包
    javaweb开发.页面中文乱码问题
    javaweb开发.eclipse使用小常识
    javaweb开发3.基于Servlet+JSP+JavaBean开发模式的用户登录注册
    ionic3使用第三方图标
    json-server使用及路由配置
    javaweb开发2.新建一个javaweb项目
  • 原文地址:https://www.cnblogs.com/xingxia/p/python_windows_base.html
Copyright © 2011-2022 走看看