Python Advanced Training camp (1) (video code) 2 Introduction 03 Tools to Improve The Efficiency of Python development 04 Review the basic Syntax of Python 05 Use the Python library to get douban film reviews and book reviews

Learn how to learn Python efficiently and systematically. Learn tools to improve Python development efficiency. Review basic Python syntax

01 Course Introduction

  1. Complete case: NLP Public opinion system

2. Python low-level function scope problem Object-oriented programming multithreading, coroutine crawler framework, Web framework course introduction

Why learn Python

  1. The Python language is popular enough
  2. The Python language is “simple” enough
  3. Ecological perfect

Python as a second language

  1. As a second language, knowledge can be transferred
  2. Front-end development can start with the reptilian project without pain
  3. Back end development can compare the differences between static and dynamic languages

Efficient ways to learn Python

  1. Establish high efficient learning model
  2. Learn about Python’s long strengths
  3. Learn about Python features
  4. Look at the high hand code (GitHub)
  5. Good questions are half the battle (Google, Stack Overflow)
  6. Wind Style Guides (PEP8, Google Python Style Guides)

03 Tools to improve Python development efficiency

Tools to improve Python development efficiency

  1. Visual Studio Code: An efficient IDE
  • pylint
  • autopep8
  • remote- ssh
  1. Python3.6 or Python3.7: What’s the difference between the different versions?
  2. Jupyter Notebook: a favorite of data scientists

Start with a request to get the titles and ratings of the Top 250 books on Douban

Implementation steps:

  1. F12 debug mode analysis of web source code
  2. Crawl the entire content of the web page with Requests
  3. Use Beautiful Soup to parse web pages to extract key information
  4. Store book names and scores in CSV files

PIP install speed up domestic common mirror station: douban tsinghua upgrade PIP: method 1: PIP install -i pypi.tuna.tsinghua.edu.cn/simple PIP -u method 2: pip config set global.index- url pypi.doubanio.com/simple/pip install pip -U

Windows: c:\Users\ XXX \ PIP \pip.ini Linux: ~ /. PIP/PIP. Conf configuration file format: [global] index – url = pypi.tuna.tsinghua.edu.cn/simple

Page turning is how to do search.bilibili.com/all?keyword… Search.douban.com/book/subjec… Weibo.com/a/aj/transf… Weibo.com/a/aj/transf…

Format strings There are three common ways to format strings:

  1. The % operator
  2. str.format(*args, **kwargs)
  3. F-string: Introduced in Python 3.6. This method is derived from PEP498

Import Math print(‘The value of Pi is approximately %5.3f.’ % Math.pi) import math print(‘The value of Pi is approximately %5.3f.

Output: The value of Pi is approximately 3.142.

. The format – more flexible print (‘ {1} and {0} ‘. The format (‘ spam ‘, ‘dense eggs’))

Output: eggs and spam

print(‘The story of {0}, {1}, and {other}.’.交流V(cmL46679910)format(‘Bill’, ‘Manfred’, other=’Georg’))

Output: The story of Bill, Manfred, and Georg.

Reference: docs.python.org/zh- cn / 3.6 / library/string html# formatstrings f – string: Python 3.6 introduced, this method is the result of PEP 498. Docs.python.org/zh-cn/3.6/w… F – string compares with the % operator and. Format:

  1. Better performance
  2. legibility

Print (‘Hello, %s %s.’ % (lastname, firstname)) print(‘Hello, %s %s.’) ‘. Format (firstname, lastname)) print(f’Hello, {lastname} {firstname}.’) f-string f'{ 2 * 5 }’ class Person: def init(self, first_name, last_name): self.first_name = first_name self.last_name = last_name def str(self): return f’hello, {self.first_name} {self.last_name}.’ def repr(self): return f’hello, {self.first_name} {self.last_name}.’ me = Person(‘yin’, ‘wilson’) print(f'{me}’)

Python 3.8 introduces the walrus operator “:=” (PEP572). You do not need to specify a type before assigning values (allocating memory).

Python execution method: Python compiles the. Py file into a bytecode PyC file, Shell > Python > ac V (cmL46679910) import whatyouwant Python > Run Python something

Conclusion:

  1. Reviewed the basic Python syntax with a static page crawler
  2. Understand the Python language as a dynamic language
  3. Master the general methods of static page data collection