Python3 爬虫实会遇到的一些困惑

2018-06-18 03:13:33来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折

最近完全被python的各种版本,安装包,工具什么的弄疯了,感觉与python相关的东西太多了,一时间让人分辨不出来到底什么是干什么的。于是,我疯狂的查阅各种资料,才逐渐慢慢理解了与python相关的各种工具和包。下面,将我的困惑记录下来,希望可以和有同样烦恼的朋友分享!

1. conda、pip和anaconda到底是干嘛的,有什么区别?

在各种网站上找了好久,最后发现其实这些问题都可以从官方网站上找到。关于conda和anaconda可以从anaconda官网找到,关于pip可以从python官网找到。下面我简单摘录一些网站上的说明供大家参考。

anaconda、miniconda和conda

什么是anaconda 
anaconda是一种开源的,易安装的高性能python和R发行版,它集成了conda包和环境管理工具,并且有1000+免费社区支持的开源包。

It is an open source, easy-to-install high performance Python and R distribution, with the conda package and environment manager and collection of 1,000+ open source packages with free community support.

为什么要用anaconda
安装python作为终端一点也不好玩。许多科学包要求python的特定版本才能运行,并且它很难使各种包交互。很难保持更新。anaconda发行版可以快速简单的获取和更新这些包。Python学习交流群125240963每天更新资料,包括2018最新企业级项目案例

Installing Python in a terminal is no joy. Many scientific packages require a specific version of Python to run, and it’s difficult to keep them from interacting with each other. It is even harder to keep them updated. Anaconda Distribution makes getting and maintaining these packages quick and easy.

什么是miniconda?
miniconda是没有1000+开源包的发行版,使用miniconda你只能使用conda命令安装你想用的包。

It’s Anaconda Distribution without the collection of 1,000+ open source packages. 
With Miniconda you install only the packages you want with the conda command,

什么是anaconda navigator?
anaconda navigator 可以非常容易的使用图形化python编程而不需要使用命令行。

Anaconda Navigator is an easy way to use graphical Python programs without having to use command line commands.

从这里我们可以知道,anaconda是一个平台,而conda是包和环境管理工具。 
在python官方文档中的安装工具建议中可以看到,pip是一个安装python包的工具。 
那么pip与conda有什么区别呢? 
conda是Anaconda Python安装的软件包管理工具。 Anaconda Python是Continuum Analytics的一个发行版,专门针对科学界,尤其是在二进制扩展安装通常很困难的Windows上。 
Conda是一个完全独立的工具,用于管理,虚拟化和轮式,但在包管理,虚拟环境管理和二进制扩展的部署方面提供了许多它们的组合功能。 
Conda不从PyPI安装软件包,只能从官方的Continuum存储库或anaconda.org(用户提供的conda软件包的地方)或本地(例如内联网)软件包服务器进行安装。 但是请注意,可以将pip安装到并且与conda一起工作来管理来自PyPI的分发。

conda is the package management tool for Anaconda Python installations. Anaconda Python is a distribution from Continuum Analytics specifically aimed at the scientific community, and in particular on Windows where the installation of binary extensions is often difficult.
Conda is a completely separate tool to pip, virtualenv and wheel, but provides many of their combined features in terms of package management, virtual environment management and deployment of binary extensions.
Conda does not install packages from PyPI and can install only from the official Continuum repositories, or anaconda.org (a place for user-contributed conda packages), or a local (e.g. intranet) package server. However, note that pip can be installed into, and work side-by-side with conda for managing distributions from PyPI.

2、什么叫做包,常用的包有哪几个,每个包的作用是什么?

从python的官方文档可以看到,模块概念的引入是为了方便代码复用,提高代码的可维护性的。如果程序越写越长,那么程序的可读性就会越来越差,程序的 层次结构也会越来越不清晰。这时,我们可以把一个较长的程序分成很多容易维护的小文件,其类似于c语言中.h文件和.c文件的作用。

If you quit from the Python interpreter and enter it again, the definitions you have made (functions and variables) are lost. Therefore, if you want to write a somewhat longer program, you are better off using a text editor to prepare the input for the interpreter and running it with that file as input instead. This is known as creating a script. As your program gets longer, you may want to split it into several files for easier maintenance. You may also want to use a handy function that you’ve written in several programs without copying its definition into each program.
To support this, Python has a way to put definitions in a file and use them in a script or in an interactive instance of the interpreter. Such a file is called a module; definitions from a module can be imported into other modules or into the main module (the collection of variables that you have access to in a script executed at the top level and in calculator mode).

而包的概念的引入是为了更方便的组织各个模块,防止相同名称的模块发生冲突,类似于c#或c++中的命名空间的作用。比如,两个不同包PA和PB都有同一个名字为M的模块,那么PA.M就表示PA包下面的模块M,PB.M就表示PB包下面的模块M。

Packages are a way of structuring Python’s module namespace by using “dotted module names”. For example, the module name A.B designates a submodule named B in a package named A. Just like the use of modules saves the authors of different modules from having to worry about each other’s global variable names, the use of dotted module names saves the authors of multi-module packages like NumPy or the Python Imaging Library from having to worry about each other’s module names.

更多关于包和模块的概念可以阅读下面两篇文章: 
廖雪峰-模块 
python基础-模块和包介绍

3、如何安装?

anaconda的安装挺简单的,只要从官方网站下载直接安装就可。pip的安装可以参考下面的文章。 
三步走安装pip 
windows下面安装Python和pip终极教程

4、python学习资源

这些资源都是我在网上找到的,仅仅在这里列出来分享一下。

  1. 强烈推荐廖雪峰的官方网站,这真是小白的福音,不管是python2还是python3。里面的内容通俗易懂,按照廖雪峰的话说就是

    中文,免费,零起点,完整示例,基于最新的Python 3版本。

  2. 知乎-Python 有哪些好的学习资料或者博客?,这里面有很多牛人提供了各种资源和链接

  3. code123.cc,这里面提供了许多实践项目,可以帮助我们快速成长。

  4. 27 个机器学习、数学、Python 速查表,这里面包含了许多机器学习和python的资料

  5. 150 多个 ML、NLP 和 Python 相关的教程,这篇文章来自于伯乐在线,这个网站里面也有很多学习资源,都非常好。

  6. python官方文档,当然官方的最权威,不过建议可以当做工具书来查,否则整天看这个不得无聊死!

  7. 网易云课堂,作为国内领先的在线课程学习平台,网易在这方面做的确实挺好。这里面有非常多的课程,可以帮助你快速的学习。当然,也有很多慕课平台,不管是国内的还是国内的,里面肯定也有很多资源,在此就不在一一列举了。

结论

当然,有这么多资源并不能保证你能学会。毕竟,只有真真正的去学你才能真真正正的学会,否则,收集了这么多资源也没什么用。其实,很多人有这种通病,有时候心血来潮,想学某个东西,网上下了一大堆资料,百度网盘存了一大堆资源,结果也只是放在那里堆灰尘而已,甚至某天发现自己有这么多资源的时候还很惊讶! 
说了那么多,其实,最重要的是去做,去行动,去实践。

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:python学习笔记--缓解眼睛疲劳的小工具

下一篇:Django Rest Framework源码剖析(四)-----API版本