没有合适的资源?快使用搜索试试~ 我知道了~
首页Python专业学习指南:英文版详解与实战
Python专业学习指南:英文版详解与实战
需积分: 49 41 下载量 182 浏览量
更新于2024-07-18
1
收藏 5.91MB PDF 举报
"《Python学习(英文版)》是一本针对专业人员设计的免费编程教程,由GoalKicker.com提供,专为教育目的创作,但并非官方Python®组织或公司的官方出版物。本书共700多页,深入浅出地讲解了Python语言的基础知识与高级技巧。
在第1章“Getting Started with Python Language”中,学习者将从入门开始,包括:
1.1 起步阶段:引导读者快速熟悉Python环境,设置基础配置。
1.2 创建变量和赋值:介绍如何声明变量以及Python中的变量类型和赋值规则。
1.3 块缩进:强调Python的特色语法——使用空格表示代码块,这是其简洁风格的重要组成部分。
1.4 数据类型:详细讲解Python中的基本数据类型,如整数、浮点数、字符串等。
1.5 集合类型:解释集合的概念,以及它们在Python中的应用。
1.6 IDLE - Python图形用户界面:介绍Python内置的集成开发环境IDLE,用于编写和调试代码。
1.7 用户输入:探讨如何在程序中接收用户输入,实现交互性。
1.8 内置模块和函数:介绍Python的核心功能模块和常用内置函数。
1.9 创建模块:指导如何创建和导入自定义模块,以便组织代码结构。
1.10 Python 2.7.x和3.x的安装:对比两个版本,并演示如何安装不同版本的Python。
1.11 字符串函数str()和repr():解析这两个函数在处理字符串时的不同作用。
1.12 使用pip安装外部模块:教授如何利用pip这个包管理器来扩展Python的功能。
1.13 帮助工具:展示如何有效利用Python的内置帮助系统获取文档和支持。
第二章“Python Data Types”深入研究各类数据类型,如:
2.1 字符串数据类型:讲解字符串的创建、操作和常见方法。
2.2 集合数据类型:进一步探索集合的特性和用法。
2.3 数字数据类型:包括整数、浮点数、复数等类型的详细介绍。
通过这些章节的学习,读者将对Python语言有全面且深入的理解,适合希望提升Python技能的专业人士使用。"
methods 470 ........................................................................................................................................................................
Section 102.1: Motivation 470 ...........................................................................................................................................
Section 102.2: Both methods implemented, eval-round-trip style __repr__() 474 ..................................................
Chapter 103: Debugging 475 ........................................................................................................................................
Section 103.1: Via IPython and ipdb 475 .........................................................................................................................
Section 103.2: The Python Debugger: Step-through Debugging with _pdb_ 475 ....................................................
Section 103.3: Remote debugger 477 .............................................................................................................................
Chapter 104: Reading and Writing CSV 478 ........................................................................................................
Section 104.1: Using pandas 478 .....................................................................................................................................
Section 104.2: Writing a TSV file 478 ..............................................................................................................................
Chapter 105: Writing to CSV from String or List 479 ......................................................................................
Section 105.1: Basic Write Example 479 ..........................................................................................................................
Section 105.2: Appending a String as a newline in a CSV file 479 ...............................................................................
Chapter 106: Dynamic code execution with `exec` and `eval` 480 .............................................................
Section 106.1: Executing code provided by untrusted user using exec, eval, or ast.literal_eval 480 .......................
Section 106.2: Evaluating a string containing a Python literal with ast.literal_eval 480 ...........................................
Section 106.3: Evaluating statements with exec 480 .....................................................................................................
Section 106.4: Evaluating an expression with eval 481 .................................................................................................
Section 106.5: Precompiling an expression to evaluate it multiple times 481 ............................................................
Section 106.6: Evaluating an expression with eval using custom globals 481 ...........................................................
Chapter 107: PyInstaller - Distributing Python Code 482 ..............................................................................
Section 107.1: Installation and Setup 482 ........................................................................................................................
Section 107.2: Using Pyinstaller 482 ................................................................................................................................
Section 107.3: Bundling to One Folder 483 .....................................................................................................................
Section 107.4: Bundling to a Single File 483 ...................................................................................................................
Chapter 108: Data Visualization with Python 484 .............................................................................................
Section 108.1: Seaborn 484 ..............................................................................................................................................
Section 108.2: Matplotlib 486 ...........................................................................................................................................
Section 108.3: Plotly 487 ...................................................................................................................................................
Section 108.4: MayaVI 489 ...............................................................................................................................................
Chapter 109: The Interpreter (Command Line Console) 491 .......................................................................
Section 109.1: Getting general help 491 ..........................................................................................................................
Section 109.2: Referring to the last expression 491 ......................................................................................................
Section 109.3: Opening the Python console 492 ............................................................................................................
Section 109.4: The PYTHONSTARTUP variable 492 ......................................................................................................
Section 109.5: Command line arguments 492 ...............................................................................................................
Section 109.6: Getting help about an object 493 ...........................................................................................................
Chapter 110: *args and **kwargs 495 .......................................................................................................................
Section 110.1: Using **kwargs when writing functions 495 ............................................................................................
Section 110.2: Using *args when writing functions 495 ..................................................................................................
Section 110.3: Populating kwarg values with a dictionary 496 .....................................................................................
Section 110.4: Keyword-only and Keyword-required arguments 496 ........................................................................
Section 110.5: Using **kwargs when calling functions 496 ............................................................................................
Section 110.6: **kwargs and default values 496 .............................................................................................................
Section 110.7: Using *args when calling functions 497 ..................................................................................................
Chapter 111: Garbage Collection 498 ........................................................................................................................
Section 111.1: Reuse of primitive objects 498 ..................................................................................................................
Section 111.2: Eects of the del command 498 ..............................................................................................................
Section 111.3: Reference Counting 499 ............................................................................................................................
Section 111.4: Garbage Collector for Reference Cycles 499 .........................................................................................
Section 111.5: Forcefully deallocating objects 500 .........................................................................................................
Section 111.6: Viewing the refcount of an object 501 .....................................................................................................
Section 111.7: Do not wait for the garbage collection to clean up 501 ........................................................................
Section 111.8: Managing garbage collection 501 ...........................................................................................................
Chapter 112: Pickle data serialisation 503 .............................................................................................................
Section 112.1: Using Pickle to serialize and deserialize an object 503 ..........................................................................
Section 112.2: Customize Pickled Data 503 ....................................................................................................................
Chapter 113: Binary Data 505 ......................................................................................................................................
Section 113.1: Format a list of values into a byte object 505 ........................................................................................
Section 113.2: Unpack a byte object according to a format string 505 ......................................................................
Section 113.3: Packing a structure 505 ............................................................................................................................
Chapter 114: Idioms 507 ..................................................................................................................................................
Section 114.1: Dictionary key initializations 507 ..............................................................................................................
Section 114.2: Switching variables 507 ............................................................................................................................
Section 114.3: Use truth value testing 507 ......................................................................................................................
Section 114.4: Test for "__main__" to avoid unexpected code execution 508 ..........................................................
Chapter 115: Data Serialization 509 ..........................................................................................................................
Section 115.1: Serialization using JSON 509 ....................................................................................................................
Section 115.2: Serialization using Pickle 509 ...................................................................................................................
Chapter 116: Multiprocessing 511 ...............................................................................................................................
Section 116.1: Running Two Simple Processes 511 .........................................................................................................
Section 116.2: Using Pool and Map 511 ...........................................................................................................................
Chapter 117: Multithreading 513 .................................................................................................................................
Section 117.1: Basics of multithreading 513 ....................................................................................................................
Section 117.2: Communicating between threads 514 ....................................................................................................
Section 117.3: Creating a worker pool 515 ......................................................................................................................
Section 117.4: Advanced use of multithreads 515 ..........................................................................................................
Section 117.5: Stoppable Thread with a while Loop 517 ...............................................................................................
Chapter 118: Processes and Threads 518 ..............................................................................................................
Section 118.1: Global Interpreter Lock 518 ......................................................................................................................
Section 118.2: Running in Multiple Threads 519 .............................................................................................................
Section 118.3: Running in Multiple Processes 520 ..........................................................................................................
Section 118.4: Sharing State Between Threads 520 .......................................................................................................
Section 118.5: Sharing State Between Processes 521 ....................................................................................................
Chapter 119: Python concurrency 522 .....................................................................................................................
Section 119.1: The multiprocessing module 522 .............................................................................................................
Section 119.2: The threading module 523 .......................................................................................................................
Section 119.3: Passing data between multiprocessing processes 523 ........................................................................
Chapter 120: Parallel computation 525 ..................................................................................................................
Section 120.1: Using the multiprocessing module to parallelise tasks 525 .................................................................
Section 120.2: Using a C-extension to parallelize tasks 525 ........................................................................................
Section 120.3: Using Parent and Children scripts to execute code in parallel 525 ....................................................
Section 120.4: Using PyPar module to parallelize 526 ..................................................................................................
Chapter 121: Sockets 527 ................................................................................................................................................
Section 121.1: Raw Sockets on Linux 527 .........................................................................................................................
Section 121.2: Sending data via UDP 527 .......................................................................................................................
Section 121.3: Receiving data via UDP 528 .....................................................................................................................
Section 121.4: Sending data via TCP 528 ........................................................................................................................
Section 121.5: Multi-threaded TCP Socket Server 528 ...................................................................................................
Chapter 122: Websockets 531 ......................................................................................................................................
Section 122.1: Simple Echo with aiohttp 531 ...................................................................................................................
Section 122.2: Wrapper Class with aiohttp 531 .............................................................................................................
Section 122.3: Using Autobahn as a Websocket Factory 532 ......................................................................................
Chapter 123: Sockets And Message Encryption/Decryption Between Client and Server
534 ............................................................................................................................................................................................
Section 123.1: Server side Implementation 534 ..............................................................................................................
Section 123.2: Client side Implementation 536 ..............................................................................................................
Chapter 124: Python Networking 538 .....................................................................................................................
Section 124.1: Creating a Simple Http Server 538 ..........................................................................................................
Section 124.2: Creating a TCP server 538 ......................................................................................................................
Section 124.3: Creating a UDP Server 539 .....................................................................................................................
Section 124.4: Start Simple HttpServer in a thread and open the browser 539 .........................................................
Section 124.5: The simplest Python socket client-server example 540 .......................................................................
Chapter 125: Python HTTP Server 541 ....................................................................................................................
Section 125.1: Running a simple HTTP server 541 .........................................................................................................
Section 125.2: Serving files 541 ........................................................................................................................................
Section 125.3: Basic handling of GET, POST, PUT using BaseHTTPRequestHandler 542 .........................................
Section 125.4: Programmatic API of SimpleHTTPServer 543 .......................................................................................
Chapter 126: Flask 545 ....................................................................................................................................................
Section 126.1: Files and Templates 545 ...........................................................................................................................
Section 126.2: The basics 545 ..........................................................................................................................................
Section 126.3: Routing URLs 546 .....................................................................................................................................
Section 126.4: HTTP Methods 547 ...................................................................................................................................
Section 126.5: Jinja Templating 547 ...............................................................................................................................
Section 126.6: The Request Object 548 ..........................................................................................................................
Chapter 127: Introduction to RabbitMQ using AMQPStorm 550 ................................................................
Section 127.1: How to consume messages from RabbitMQ 550 ..................................................................................
Section 127.2: How to publish messages to RabbitMQ 551 .........................................................................................
Section 127.3: How to create a delayed queue in RabbitMQ 551 ................................................................................
Chapter 128: Descriptor 554 .........................................................................................................................................
Section 128.1: Simple descriptor 554 ...............................................................................................................................
Section 128.2: Two-way conversions 555 .......................................................................................................................
Chapter 129: tempfile NamedTemporaryFile 556 .............................................................................................
Section 129.1: Create (and write to a) known, persistent temporary file 556 .............................................................
Chapter 130: Input, Subset and Output External Data Files using Pandas 557 .................................
Section 130.1: Basic Code to Import, Subset and Write External Data Files Using Pandas 557 ...............................
Chapter 131: Unzipping Files 559 ................................................................................................................................
Section 131.1: Using Python ZipFile.extractall() to decompress a ZIP file 559 ............................................................
Section 131.2: Using Python TarFile.extractall() to decompress a tarball 559 ...........................................................
Chapter 132: Working with ZIP archives 560 ........................................................................................................
Section 132.1: Examining Zipfile Contents 560 ...............................................................................................................
Section 132.2: Opening Zip Files 560 ...............................................................................................................................
Section 132.3: Extracting zip file contents to a directory 561 .......................................................................................
Section 132.4: Creating new archives 561 ......................................................................................................................
Chapter 133: Getting start with GZip 562 ..............................................................................................................
Section 133.1: Read and write GNU zip files 562 ............................................................................................................
Chapter 134: Stack 563 ...................................................................................................................................................
Section 134.1: Creating a Stack class with a List Object 563 ........................................................................................
Section 134.2: Parsing Parentheses 564 .........................................................................................................................
Chapter 135: Working around the Global Interpreter Lock (GIL) 565 .....................................................
Section 135.1: Multiprocessing.Pool 565 ..........................................................................................................................
Section 135.2: Cython nogil: 566 ......................................................................................................................................
Chapter 136: Deployment 567 .....................................................................................................................................
Section 136.1: Uploading a Conda Package 567 ............................................................................................................
Chapter 137: Logging 569 ..............................................................................................................................................
Section 137.1: Introduction to Python Logging 569 ........................................................................................................
Section 137.2: Logging exceptions 570 ...........................................................................................................................
Chapter 138: Web Server Gateway Interface (WSGI) 573 .............................................................................
Section 138.1: Server Object (Method) 573 .....................................................................................................................
Chapter 139: Python Server Sent Events 574 ......................................................................................................
Section 139.1: Flask SSE 574 .............................................................................................................................................
Section 139.2: Asyncio SSE 574 ........................................................................................................................................
Chapter 140: Alternatives to switch statement from other languages 575 .......................................
Section 140.1: Use what the language oers: the if/else construct 575 .....................................................................
Section 140.2: Use a dict of functions 575 ......................................................................................................................
Section 140.3: Use class introspection 576 .....................................................................................................................
Section 140.4: Using a context manager 577 ................................................................................................................
Chapter 141: List destructuring (aka packing and unpacking) 578 .........................................................
Section 141.1: Destructuring assignment 578 .................................................................................................................
Section 141.2: Packing function arguments 579 ............................................................................................................
Section 141.3: Unpacking function arguments 581 ........................................................................................................
Chapter 142: Accessing Python source code and bytecode 582 ..............................................................
Section 142.1: Display the bytecode of a function 582 ..................................................................................................
Section 142.2: Display the source code of an object 582 .............................................................................................
Section 142.3: Exploring the code object of a function 583 ..........................................................................................
Chapter 143: Mixins 584 ..................................................................................................................................................
Section 143.1: Mixin 584 .....................................................................................................................................................
Section 143.2: Overriding Methods in Mixins 585 ...........................................................................................................
Chapter 144: Attribute Access 586 ...........................................................................................................................
Section 144.1: Basic Attribute Access using the Dot Notation 586 ...............................................................................
Section 144.2: Setters, Getters & Properties 586 ............................................................................................................
Chapter 145: ArcPy 588 ..................................................................................................................................................
Section 145.1: createDissolvedGDB to create a file gdb on the workspace 588 ........................................................
Section 145.2: Printing one field's value for all rows of feature class in file geodatabase using Search
Cursor 588 .................................................................................................................................................................
Chapter 146: Abstract Base Classes (abc) 589 ...................................................................................................
Section 146.1: Setting the ABCMeta metaclass 589 .......................................................................................................
Section 146.2: Why/How to use ABCMeta and @abstractmethod 589 ......................................................................
Chapter 147: Plugin and Extension Classes 591 .................................................................................................
Section 147.1: Mixins 591 ...................................................................................................................................................
Section 147.2: Plugins with Customized Classes 592 .....................................................................................................
Chapter 148: Immutable datatypes(int, float, str, tuple and frozensets) 594 ..................................
Section 148.1: Individual characters of strings are not assignable 594 .......................................................................
Section 148.2: Tuple's individual members aren't assignable 594 ...............................................................................
Section 148.3: Frozenset's are immutable and not assignable 594 .............................................................................
Chapter 149: Incompatibilities moving from Python 2 to Python 3 595 ................................................
Section 149.1: Integer Division 595 ...................................................................................................................................
Section 149.2: Unpacking Iterables 596 ..........................................................................................................................
Section 149.3: Strings: Bytes versus Unicode 598 ..........................................................................................................
Section 149.4: Print statement vs. Print function 600 ....................................................................................................
Section 149.5: Dierences between range and xrange functions 601 ........................................................................
Section 149.6: Raising and handling Exceptions 602 .....................................................................................................
Section 149.7: Leaked variables in list comprehension 604 ..........................................................................................
Section 149.8: True, False and None 605 ........................................................................................................................
Section 149.9: User Input 605 ...........................................................................................................................................
Section 149.10: Comparison of dierent types 606 .......................................................................................................
Section 149.11: .next() method on iterators renamed 606 .............................................................................................
Section 149.12: filter(), map() and zip() return iterators instead of sequences 607 ...................................................
Section 149.13: Renamed modules 607 ...........................................................................................................................
Section 149.14: Removed operators <> and ``, synonymous with != and repr() 608 ...................................................
Section 149.15: long vs. int 608 .........................................................................................................................................
Section 149.16: All classes are "new-style classes" in Python 3 609 ............................................................................
Section 149.17: Reduce is no longer a built-in 610 .........................................................................................................
Section 149.18: Absolute/Relative Imports 610 ..............................................................................................................
Section 149.19: map() 612 ................................................................................................................................................
Section 149.20: The round() function tie-breaking and return type 613 ....................................................................
Section 149.21: File I/O 614 ..............................................................................................................................................
Section 149.22: cmp function removed in Python 3 614 ...............................................................................................
Section 149.23: Octal Constants 615 ...............................................................................................................................
Section 149.24: Return value when writing to a file object 615 ....................................................................................
Section 149.25: exec statement is a function in Python 3 615 ......................................................................................
Section 149.26: encode/decode to hex no longer available 616 .................................................................................
Section 149.27: Dictionary method changes 617 ..........................................................................................................
Section 149.28: Class Boolean Value 617 .......................................................................................................................
Section 149.29: hasattr function bug in Python 2 618 ...................................................................................................
Chapter 150: 2to3 tool 619 ............................................................................................................................................
Section 150.1: Basic Usage 619 ........................................................................................................................................
Chapter 151: Non-ocial Python implementations 621 ................................................................................
Section 151.1: IronPython 621 ...........................................................................................................................................
Section 151.2: Jython 621 .................................................................................................................................................
Section 151.3: Transcrypt 622 ..........................................................................................................................................
Chapter 152: Abstract syntax tree 625 ...................................................................................................................
Section 152.1: Analyze functions in a python script 625 ................................................................................................
Chapter 153: Unicode and bytes 627 .......................................................................................................................
Section 153.1: Encoding/decoding error handling 627 ..................................................................................................
Section 153.2: File I/O 627 ................................................................................................................................................
Section 153.3: Basics 628 ..................................................................................................................................................
Chapter 154: Python Serial Communication (pyserial) 630 .........................................................................
Section 154.1: Initialize serial device 630 .........................................................................................................................
Section 154.2: Read from serial port 630 .......................................................................................................................
Section 154.3: Check what serial ports are available on your machine 630 ..............................................................
Chapter 155: Neo4j and Cypher using Py2Neo 632 .........................................................................................
Section 155.1: Adding Nodes to Neo4j Graph 632 ..........................................................................................................
剩余813页未读,继续阅读
282 浏览量
1002 浏览量
3175 浏览量
2396 浏览量
567 浏览量
1310 浏览量
1035 浏览量
三爻三爻
- 粉丝: 1
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Windows下Apache+Tomcat+MySQL+jsp+php的服务器整合配置经验总结
- Delphi下用IntraWeb开发WEB程序应用实战
- Jsp+tomcat+mysql for WindowsXP
- microsoft c# 认证题库
- Eigenfaces for Face Detection
- Linux网络文件系统分析(NFS)
- 数据通信基础知识.pdf
- 最佳46款免费软件(同步精译版)
- JAVA语言版数据结构与算法
- PC_MODBUS;PC与PLC.doc
- DWR 入門與應用-林信良
- 关于spring的pdf书
- 学习oracle笔记
- 基于Matlab的遗传算法实现
- 12学会FreeBSD安装笔记
- proteus完整教程(英文版).pdf
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功