人工智能微刊人工智能(语言识别&图像识别)AI人工智能与数学之美

菜鸟学习人工智能第七期:模块(就是程序),文末有免费学习资料

2019-08-13  本文已影响12人  KangSmit的算法那些事儿

7.1 模块即程序

在Py的安装目录下调用hello模块, hello.py中的代码块

def haha():
    print("我爱你,中国!")
1.JPG

@w=100

下面在命令窗口导入该模块


>>> import hello
Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    import hello
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\hello.py", line 2
SyntaxError: (unicode error) 'utf-8' codec can't decode byte 0xce in position 0: invalid continuation byte

上述一开始导入模块就报错的原因是记事本保存的时候没有设置为UTF-8的形式保存(切记不要犯错),所以要重新修改后的运行结果

>>> import hello
>>> haha()
Traceback (most recent call last):
  File "<pyshell#4>", line 1, in <module>
    haha()
NameError: name 'haha' is not defined

此时,出错的原因是找不到haha()函数,因为提示无定义,为了解决这个问题我们需要引入一个概念:

7.2命名空间(Namespace)表示标识符的可见范围

一个标识符可在多个命名空间中定义,他在多个命名空间互不相干,
例如:两个班级都有“”姚明“”这个名字,但是在期末考试的全校成绩排名的时候名单上就不知道姚明是哪个班的了,因此我们在调用的函数前面添加班级名(也就是标识符)就可以了。
简单来说就是你在安装目录下命名的hello.py文件名即hello(标识符),那么如何来解决,其实只需要

>>> hello.haha()
我爱你,中国!

7.3模块的导入

1. import模块名

再写一个例子(同样在安装目录下操作):temp.py

def Ta(cel):
    fah = cel * 1.8 + 32
    return fah

def Tb(fah):
    cel = (fah - 32) / 1.8
    return cel

类似地,我们也可以调用得到

>>> print("26.0摄氏度 = %.2f华氏度" % temp.Ta(26.0))
26.0摄氏度 = 78.80华氏度
>>> print("98.0华氏度 = %.2f摄氏度" % temp.Tb(98.0))
98.0华氏度 = 36.67摄氏度

2. from模块名 import函数名

上述模块导入的命名空间有时太长也不太好,这样带来不便,每次都要重复输入,给读者的阅读体验也不是很好。为了解决这个不便捷的方法,我们使用下面的一种技巧可以将命名空间直接覆盖进来,调用时不再加上命名空间。

>>> from temp import Ta, Tb
>>> print("26.0摄氏度 = %.2f华氏度" % Ta(26.0))
26.0摄氏度 = 78.80华氏度
>>> print("98.0华氏度 = %.2f摄氏度" % Tb(98.0))
98.0华氏度 = 36.67摄氏度

也可以使用通配符号(*)来导入模块中的所有命名空间(不建议使用,因为有时会陷入名字混乱)

>>> from temp import *
>>> print("26.0摄氏度 = %.2f华氏度" % Ta(26.0))
26.0摄氏度 = 78.80华氏度
>>> print("98.0华氏度 = %.2f摄氏度" % Tb(98.0))
98.0华氏度 = 36.67摄氏度

3.import模块名as 新名字(推荐使用)

替换一个新的名字(但可以不改变按住目录下的名字)

>>> import temp as tp
>>> print("26.0摄氏度 = %.2f华氏度" % tp.Ta(26.0))
26.0摄氏度 = 78.80华氏度
>>> print("98.0华氏度 = %.2f摄氏度" % tp.Tb(98.0))
98.0华氏度 = 36.67摄氏度

7.4__name__ == '__main__'

在很多代码程序中都有
if__name__ == '__main__'
为了解释这个代码,我先给大家举出一个列子,下面这是不测试的情况,思路与上面一样。

def Ta(cel):
    fah = cel * 1.8 + 32
    return fah

def Tb(fah):
    cel = (fah - 32) / 1.8
    return cel

def test():
    print("26.0摄氏度 = %.2f华氏度" % Ta(26.0))
    print("98.0华氏度 = %.2f摄氏度" % Tb(98.0))

调用

>>> test()
26.0摄氏度 = 78.80华氏度
98.0华氏度 = 36.67摄氏度

测试之后可以直接单独运行

ef Ta(cel):
    fah = cel * 1.8 + 32
    return fah

def Tb(fah):
    cel = (fah - 32) / 1.8
    return cel

def test():
    print("测试,0摄氏度 = %.2f华氏度" % Ta(0))
    print("测试,0华氏度 = %.2f摄氏度" % Tb(0))

test()

运行结果

>>> 
=================== RESTART: F:\Pypractise\第七期:模块\temp2.py ===================
测试,0摄氏度 = 32.00华氏度
测试,0华氏度 = -17.78摄氏度

这里要注意的是如果是在另一个文件中(temp.py(在C盘安装目录下)),导入后再调用会出现一块儿执行的情况问题(略)。

为了避免这个情况发生,关键是在于:要让Python知道该模块是作为程序运行还是导入到其他程序中,这一点一定要明确区分。为了实现这一点,需要使用模块的name属性:

>>> __name__
'__main__'
>>> tc.__name__
'temp'

那么,从上面可以看出,name属性值是 '__main__',而作为模块导入的时候,这个值就是该模块的名字了。对于代码__name__ == '__main__'的理解就有思路了。

def Ta(cel):
    fah = cel * 1.8 + 32
    return fah

def Tb(fah):
    cel = (fah - 32) / 1.8
    return cel

def test():
    print("测试,0摄氏度 = %.2f华氏度" % Ta(0))
    print("测试,0华氏度 = %.2f摄氏度" % Tb(0))
if __name__ == '__main__':
     test()

运行结果

>>> 
=================== RESTART: F:/Pypractise/第七期:模块/temp3.py ===================
测试,0摄氏度 = 32.00华氏度
测试,0华氏度 = -17.78摄氏度

这样就确保了只有单独运行temp3.py时才会执行test()函数。(从而解决测试函数出现一块儿执行的情况)

7.5 如何进行搜索路劲

方案:写好的模块放在和导入这个模块文件的源代码同一个文件夹内,但是有一些读者可能不希望把所有代码都放在一个篮子里。因为我们想通过文件夹的方式更好的组织我的代码。

搜索路劲(一组目录):就是我们一开始导入一个叫hello.py的模块文件,如果模块存在,则调用不报错;否则,报错即导入失败。
其次,搜索路劲(一组目录)可以通过sys模块中的path变量显示出来(简单来说就是模块存在的位置)

>>> import sys
>>> sys.path
['F:/Pypractise/第七期:模块', 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python37-32\\Lib\\idlelib', 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python37-32\\Lib\\site-packages\\easygui-0.98.0_UNRELEASED-py3.7.egg\\easygui', 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python37-32\\python37.zip', 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python37-32\\DLLs', 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python37-32\\lib', 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python37-32', 'C:\\Users\\Administrator\\AppData\\Roaming\\Python\\Python37\\site-packages', 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages', 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages\\easygui-0.98.0_unreleased-py3.7.egg', 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages\\pelican-4.1.0-py3.7.egg', 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages\\unidecode-1.1.1-py3.7.egg', 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages\\blinker-1.4-py3.7.egg', 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages\\pytz-2019.1-py3.7.egg', 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages\\docutils-0.14-py3.7.egg', 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages\\pygments-2.4.2-py3.7.egg', 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages\\jinja2-2.10.1-py3.7.egg', 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages\\feedgenerator-1.9-py3.7.egg', 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages\\markupsafe-1.1.1-py3.7-win32.egg']

列出的这些模块都是前面我们在Python导入过的模块时去搜索的(有记录导入模块的作用)。尽管这些模块都可以使用,但是site-packages目录是最佳的选择,因为从上面的代码中可以看出它(site-packages)就是用来做这些事情的。

按照以上的逻辑来说,只要知道模块的位置在哪里,Python自然能正确找到相应的位置对模块进行导入:
如果存放模块的位置是C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32

>>> import temp2
Traceback (most recent call last):
  File "<pyshell#13>", line 1, in <module>
    import temp3
ModuleNotFoundError: No module named 'temp2

直接导入模块显然出错,主要是因为搜索路劲不包括模块的位置,如果把模块的位置添加到搜索路劲中就可以了

当你导入一个模块,Python 解析器对模块位置的搜索顺序是:
1、当前目录
2、如果不在当前目录,Python 则搜索在 shell 变量 PYTHONPATH 下的每个目录。
3、如果都找不到,Python会察看默认路径。UNIX下,默认路径一般为/usr/local/lib/python/。
模块搜索路径存储在 system 模块的 sys.path 变量中。
变量里包含当前目录,PYTHONPATH和由安装过程决定的默认目录。

7.6 什么是包,包的作用

包:把模块分门类别存放在不同的文件夹,然后把每个文件夹的位置告诉Python.

创建一个包的具体操作如下:
(1)创建一个文件夹,用于存放指定的模块,文件夹的名字就是包的名字;
(2)在文件夹中创建一个的模块文件,内容可以为空;
(3)将指定的模块放入文件夹(包)中。
举例,目录结构如下(记事本保存时选择utf-8):
test.py
package
|-- init.py
|-- task1.py
|-- task2.py

源代码如下:
packageround/task1.py
def task1():
print "I'm in task1"

packageround/task2.py
def task2():
print "I'm in task2"
现在,在 package 目录下创建 init.py:

packageround/init.py

if name == 'main':
print '作为主程序运行'
else:
print 'packageround 初始化'
然后我们在 packageround 同级目录下创建 test.py 来调用 packageround 包

test.py

导入 Phone 包

from packageround.task1 import task1
from packageround.task2 import task2

task1()
task2()
以上实例输出结果:

packageround 初始化
I'm in task1
I'm in task2

或者也可以这样l理解:
包是一个分层次的文件目录结构,它定义了一个由模块及子包,和子包下的子包等组成的 Python 的应用环境。
简单来说,包就是文件夹,但该文件夹下必须存在__init__.py文件, 该文件的内容可以为空。
__init__.py用于标识当前文件夹是一个包。

7.7 标准库里的模块

Python的标准库有上百种,一个一个的讲是不现实的,毕竟时间有限。因此,本小节只论述部分标准库的使用,其余的库会在文章末尾以附件形式展示。

对于一个开发者来说不得不了解Python的文档,该文档包含了学习资料和教程。可以在解释器中打开help——>Doc, 调出如下
[图片上传失败...(image-b3ea7e-1565796561052)] @w=400
这里面的内容非常详细,大家可以看看,对于标准库太多的情况下,最好的就是当字典来用,当自己用到了就查询一下即可。也可以通过下面的网站查询:

Python库参考(被称为Python枕边书)
https://docs.python.org/2.4/lib/lib.html

4.JPG

关于Python的第三方模块的安装我在前几期讲过了,这里就不在重复,我使用的是在win7下进行的,cmd打开运行,使用如下的命令就可以运行安装了(只举几个)
win系统的模块安装命令:
python -m pip install * (* 代表模块名)
例如:
python -m pip install matplotlib
python -m pip install scipy
python -m pip install sympy
python -m pip install numpy
python -m pip install opencv-python#图像处理模块

还可以通过网站:
https://docs.python.org/3/distributing/index.html
来了解如何发布Python的第三方文件(该网站也给出 了很多模块安装教程)

5.JPG @w=400

如果我们不知道哪一个模块的用法,应该从何处下手?
下面以timeit模块为例:
在刚刚的Python文档下可以查询,索引下输入timeit就可以查到


6.JPG

点击进入模块就可以详细了解模块的用法了。

上述timeit模块的用法是测试小段代码的执行时间


7.JPG

该模块的优势:灵活避开了测量执行时间容易出现的错误,
上图就是给出的一个例子。
但是如果按照这样去查每个模块的函数,类的用法太繁琐了,因此我们只需要通过相应的命令就可以查询到模块用法:
(调用doc文档,用print打印出来。)

>>> import timeit
>>> print(timeit.__doc__)
Tool for measuring execution time of small code snippets.

This module avoids a number of common traps for measuring execution
times.  See also Tim Peters' introduction to the Algorithms chapter in
the Python Cookbook, published by O'Reilly.

Library usage: see the Timer class.

Command line usage:
    python timeit.py [-n N] [-r N] [-s S] [-p] [-h] [--] [statement]

Options:
  -n/--number N: how many times to execute 'statement' (default: see below)
  -r/--repeat N: how many times to repeat the timer (default 5)
  -s/--setup S: statement to be executed once initially (default 'pass').
                Execution time of this setup statement is NOT timed.
  -p/--process: use time.process_time() (default is time.perf_counter())
  -v/--verbose: print raw timing results; repeat for more digits precision
  -u/--unit: set the output time unit (nsec, usec, msec, or sec)
  -h/--help: print this usage message and exit
  --: separate options from statement, use when statement starts with -
  statement: statement to be timed (default 'pass')

A multi-line statement may be given by specifying each line as a
separate argument; indented lines are possible by enclosing an
argument in quotes and using leading spaces.  Multiple -s options are
treated similarly.

If -n is not given, a suitable number of loops is calculated by trying
successive powers of 10 until the total time is at least 0.2 seconds.

Note: there is a certain baseline overhead associated with executing a
pass statement.  It differs between versions.  The code here doesn't try
to hide it, but you should be aware of it.  The baseline overhead can be
measured by invoking the program without arguments.

Classes:

    Timer

Functions:

    timeit(string, string) -> float
    repeat(string, string) -> list
    default_timer() -> float

使用dir()函数可以查询到模块定义了那些变量、函数和类:

>>> dir(timeit)
['Timer', '__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', '_globals', 'default_number', 'default_repeat', 'default_timer', 'dummy_src_name', 'gc', 'itertools', 'main', 'reindent', 'repeat', 'sys', 'template', 'time', 'timeit']

不过上述的这些名字对我们来说并不是都能用到,因此我们可以过滤掉一下东西(筛选),比如上面的代码块中的all属性,它可以帮助我们完成这样一项过滤操作:

>>> timeit.__all__
['Timer', 'timeit', 'repeat', 'default_timer']

还可以使用help()函数查询详细的模块用法:

>>> help(timeit)
Help on module timeit:

NAME
    timeit - Tool for measuring execution time of small code snippets.

DESCRIPTION
    This module avoids a number of common traps for measuring execution
    times.  See also Tim Peters' introduction to the Algorithms chapter in
    the Python Cookbook, published by O'Reilly.
    
    Library usage: see the Timer class.
    
    Command line usage:
        python timeit.py [-n N] [-r N] [-s S] [-p] [-h] [--] [statement]
    
    Options:
      -n/--number N: how many times to execute 'statement' (default: see below)
      -r/--repeat N: how many times to repeat the timer (default 5)
      -s/--setup S: statement to be executed once initially (default 'pass').
                    Execution time of this setup statement is NOT timed.
      -p/--process: use time.process_time() (default is time.perf_counter())
      -v/--verbose: print raw timing results; repeat for more digits precision
      -u/--unit: set the output time unit (nsec, usec, msec, or sec)
      -h/--help: print this usage message and exit
      --: separate options from statement, use when statement starts with -
      statement: statement to be timed (default 'pass')
    
    A multi-line statement may be given by specifying each line as a
    separate argument; indented lines are possible by enclosing an
    argument in quotes and using leading spaces.  Multiple -s options are
    treated similarly.
    
    If -n is not given, a suitable number of loops is calculated by trying
    successive powers of 10 until the total time is at least 0.2 seconds.
    
    Note: there is a certain baseline overhead associated with executing a
    pass statement.  It differs between versions.  The code here doesn't try
    to hide it, but you should be aware of it.  The baseline overhead can be
    measured by invoking the program without arguments.
    
    Classes:
    
        Timer
    
    Functions:
    
        timeit(string, string) -> float
        repeat(string, string) -> list
        default_timer() -> float

CLASSES
    builtins.object
        Timer
    
    class Timer(builtins.object)
     |  Timer(stmt='pass', setup='pass', timer=<built-in function perf_counter>, globals=None)
     |  
     |  Class for timing execution speed of small code snippets.
     |  
     |  The constructor takes a statement to be timed, an additional
     |  statement used for setup, and a timer function.  Both statements
     |  default to 'pass'; the timer function is platform-dependent (see
     |  module doc string).  If 'globals' is specified, the code will be
     |  executed within that namespace (as opposed to inside timeit's
     |  namespace).
     |  
     |  To measure the execution time of the first statement, use the
     |  timeit() method.  The repeat() method is a convenience to call
     |  timeit() multiple times and return a list of results.
     |  
     |  The statements may contain newlines, as long as they don't contain
     |  multi-line string literals.
     |  
     |  Methods defined here:
     |  
     |  __init__(self, stmt='pass', setup='pass', timer=<built-in function perf_counter>, globals=None)
     |      Constructor.  See class doc string.
     |  
     |  autorange(self, callback=None)
     |      Return the number of loops and time taken so that total time >= 0.2.
     |      
     |      Calls the timeit method with increasing numbers from the sequence
     |      1, 2, 5, 10, 20, 50, ... until the time taken is at least 0.2
     |      second.  Returns (number, time_taken).
     |      
     |      If *callback* is given and is not None, it will be called after
     |      each trial with two arguments: ``callback(number, time_taken)``.
     |  
     |  print_exc(self, file=None)
     |      Helper to print a traceback from the timed code.
     |      
     |      Typical use:
     |      
     |          t = Timer(...)       # outside the try/except
     |          try:
     |              t.timeit(...)    # or t.repeat(...)
     |          except:
     |              t.print_exc()
     |      
     |      The advantage over the standard traceback is that source lines
     |      in the compiled template will be displayed.
     |      
     |      The optional file argument directs where the traceback is
     |      sent; it defaults to sys.stderr.
     |  
     |  repeat(self, repeat=5, number=1000000)
     |      Call timeit() a few times.
     |      
     |      This is a convenience function that calls the timeit()
     |      repeatedly, returning a list of results.  The first argument
     |      specifies how many times to call timeit(), defaulting to 5;
     |      the second argument specifies the timer argument, defaulting
     |      to one million.
     |      
     |      Note: it's tempting to calculate mean and standard deviation
     |      from the result vector and report these.  However, this is not
     |      very useful.  In a typical case, the lowest value gives a
     |      lower bound for how fast your machine can run the given code
     |      snippet; higher values in the result vector are typically not
     |      caused by variability in Python's speed, but by other
     |      processes interfering with your timing accuracy.  So the min()
     |      of the result is probably the only number you should be
     |      interested in.  After that, you should look at the entire
     |      vector and apply common sense rather than statistics.
     |  
     |  timeit(self, number=1000000)
     |      Time 'number' executions of the main statement.
     |      
     |      To be precise, this executes the setup statement once, and
     |      then returns the time it takes to execute the main statement
     |      a number of times, as a float measured in seconds.  The
     |      argument is the number of times through the loop, defaulting
     |      to one million.  The main statement, the setup statement and
     |      the timer function to be used are passed to the constructor.
     |  
     |  ----------------------------------------------------------------------
     |  Data descriptors defined here:
     |  
     |  __dict__
     |      dictionary for instance variables (if defined)
     |  
     |  __weakref__
     |      list of weak references to the object (if defined)

FUNCTIONS
    default_timer = perf_counter(...)
        perf_counter() -> float
        
        Performance counter for benchmarking.
    
    repeat(stmt='pass', setup='pass', timer=<built-in function perf_counter>, repeat=5, number=1000000, globals=None)
        Convenience function to create Timer object and call repeat method.
    
    timeit(stmt='pass', setup='pass', timer=<built-in function perf_counter>, number=1000000, globals=None)
        Convenience function to create Timer object and call timeit method.

DATA
    __all__ = ['Timer', 'timeit', 'repeat', 'default_timer']

FILE
    c:\users\administrator\appdata\local\programs\python\python37-32\lib\timeit.py

如果看不太懂python的文档,可以翻译或者百度搜索一下即可。

下面是Python标准库的归纳:
导读:Python数据工具箱涵盖从数据源到数据可视化的完整流程中涉及到的常用库、函数和外部工具。其中既有Python内置函数和标准库,又有第三方库和工具。

这些库可用于文件读写、网络抓取和解析、数据连接、数清洗转换、数据计算和统计分析、图像和视频处理、音频处理、数据挖掘/机器学习/深度学习、数据可视化、交互学习和集成开发以及其他Python协同数据工作工具。

python 资料获取方式:转发+私信【Python】

阅读文本大概需要 32 分钟。

吐血整理!140种Python标准库、第三方库和外部工具都有了

为了区分不同对象的来源和类型,本文将在描述中通过以下方法进行标识:

abs(-3.2)

import string

string.find('abcde','b')

推荐度」3星最高,1星最低。

01 文件读写

文件的读写包括常见的txt、Excel、xml、二进制文件以及其他格式的数据文本,主要用于本地数据的读写。

吐血整理!140种Python标准库、第三方库和外部工具都有了

1. open(name[, mode[, buffering]])

2. numpy.loadtxt、numpy.load和numpy.fromfile

3. pandas.read_*

4. xlrd

5. xlwt

6. pyexcel-xl

7. xluntils

8. pyExcelerator

9. openpyxl

10. lxml

11. xml

12. libxml2

13. xpath

14. win32com

02 网络抓取和解析

网络抓取和解析用于从互联网中抓取信息,并对HTML对象进行处理,有关xml对象的解析和处理的库在“01 文件读写”中找到。

吐血整理!140种Python标准库、第三方库和外部工具都有了

python 资料获取方式:转发+私信【Python】

15. requests

16. urllib

17. urllib2

18. urlparse

19. HTMLParser

20. Scapy

21. Beautiful Soup

03 数据库连接

数据库连接可用于连接众多数据库以及访问通用数据库接口,可用于数据库维护、管理和增、删、改、查等日常操作。

吐血整理!140种Python标准库、第三方库和外部工具都有了

22. mysql-connector-python

23. pymysql

24. MySQL-python

25. cx_Oracle

26. psycopg2

27. redis

28. pymongo

29. HappyBase

30. py2neo

31. cassandra-driver

32. sqlite3

33. pysqlite2

34. bsddb3

35. bsddb

36. dbhash

37. adodb

38. SQLObject

39. SQLAlchemy

40. ctypes

41. pyodbc

42. Jython

04 数据清洗转换

数据清洗转换主用于数据正式应用之前的预处理工作。

吐血整理!140种Python标准库、第三方库和外部工具都有了

python 资料获取方式:转发+私信【Python】

43. frozenset([iterable])

44. int(x)

45. isinstance(object, classinfo)

46. len(s)

47. long(x)

48. max(iterable[, key])

49. min(iterable[, key])

50. range(start, stop[, step])

51. raw_input(prompt)

52. round(number[, ndigits])

53. set([iterable])

54. slice(start, stop[, step])

55. sorted(iterable[, cmp[, key[, reverse]]])

56. xrange(start, stop[, step])

57. string

58. re

59. random

60. os

61. os.path

62. prettytable

63. json

64. base64

05 数据计算和统计分析

数据计算和统计分析主要用于数据探查、计算和初步数据分析等工作。

吐血整理!140种Python标准库、第三方库和外部工具都有了

python 资料获取方式:转发+私信【Python】

65. numpy

66. scipy

67. pandas

68. statsmodels

69. abs(x)

70. cmp(x, y)

71. float(x)

72. pow(x, y[, z])

73. sum(iterable[, start])

74. math

75. cmath

76. decimal

77. fractions

06 自然语言处理和文本挖掘

自然语言处理和文本挖掘库主要用于以自然语言文本为对象的数据处理和建模。

吐血整理!140种Python标准库、第三方库和外部工具都有了

78. nltk

79. pattern

80. gensim

81. 结巴分词

82. SnowNLP

83. smallseg

84. spaCy

85. TextBlob

86. PyNLPI

87. synonyms

07 图像和视频处理

图像处理和视频处理主要适用于基于图像的操作、处理、分析和挖掘,如人脸识别、图像识别、目标跟踪、图像理解等。

吐血整理!140种Python标准库、第三方库和外部工具都有了

python 资料获取方式:转发+私信【Python】

88. PIL/Pillow

89. OpenCV

90. scikit-image

91. imageop

92. colorsys

93. imghdr

08 音频处理

音频处理主要适用于基于声音的处理、分析和建模,主要应用于语音识别、语音合成、语义理解等。

吐血整理!140种Python标准库、第三方库和外部工具都有了

94. TimeSide

95. audiolazy

96. pydub

97. audioop

98. tinytag

99. aifc

100. sunau

101. wave

102. chunk

103. sndhdr

104. ossaudiodev

09 数据挖掘/机器学习/深度学习

数据挖掘、机器学习和深度学习等是Python进行数据建模和挖掘学习的核心模块。

吐血整理!140种Python标准库、第三方库和外部工具都有了

105. Scikit-Learn

106. TensorFlow

107. NuPIC

108. PyTorch

109. Orange

110. theano

111. keras

112. neurolab

113. PyLearn2

114. OverFeat

115. Pyevolve

116. Caffe2

10 数据可视化

数据可视化主要用于做数据结果展示、数据模型验证、图形交互和探查等方面。

吐血整理!140种Python标准库、第三方库和外部工具都有了

python 资料获取方式:转发+私信【Python】

117. Matplotlib

118. pyecharts

119. seaborn

120. bokeh

121. Plotly

122. VisPy

123. PyQtGraph

124. ggplot

11 交互学习和集成开发

交互学习和集成开发主要用来做Python开发、调试和集成之用,包括Python集成开发环境和IDE。

吐血整理!140种Python标准库、第三方库和外部工具都有了

125. IPython/ Jupyter

126. Elpy

127. PTVS

128. PyCharm

129. LiClipse

130. Spyder

12 其他Python协同数据工作工具

其他Python协同数据工作工具指除了上述主题以外,其他在数据工作中常用的工具或库。

131. tesseract-ocr

132. RPython

133. Rpy2

134. matpython

135. Lunatic Python

136. PyCall.jl

137. PySpark

138. dumbo

139. dpark

140. streamparse

资料免费领取请到我的微信公众号领取

w
上一篇 下一篇

猜你喜欢

热点阅读