current position:Home>Python learning process and bug

Python learning process and bug

2022-02-01 20:58:07 Pikachu who knows Baidu

「 Time is not negative , Create constantly , This article is participating in 2021 Year end summary essay contest

I learned... This year python All those things that you're looking for ?

  1. Flask frame (bug)
  2. python Third party Library requests And internal library urllib
  3. Scrapy The crawler frame
  4. Django frame

Flask Summary of

Flask It's a lightweight customizable framework , Use Python Language writing , More flexible than other similar frameworks 、 Light 、 Safe and easy to use ......... Keep your code simple and easy to extend ,Flask The main feature of the framework is that the core structure is relatively simple , But it has strong expansibility and compatibility , Programmers can use Python Language quickly realizes a website or Web service .
 This is a Flask An introduction to the , Wrote for a while Flask Found it really easy to build , And the code is more convenient , There is a problem when writing the project package , But it's not Flask Packing problem , But there are... Inside the code when packaging PaddlePaddle Third party Library of the framework , About it bug, I have to mention .
 The packaged third-party library is Pyinstaller, The order is pyinstall -F app.py, It should be noted that app.py There is a configuration file equivalent to app.spec, Some configuration file paths before packaging can be written to . But no matter what you write, the final package will generate two folders ,build and dist, Many frames are packaged in this style , Look at it anyway dist Of the contents of ,dist Medium app.exe It's an executive document , But the default is naked exe file , To run, you have to put the template file , Copy static resource files to dist Under folder .
 Copy code 
 The emergence of bug:
     Double-click to open exe, Ten minutes later, the error message flashes .
     Solution :  Open the directory folder , Find the box of the directory , Add... To the front “cmd ” Enter and jump to the command line , On the command line app.exe. You can see the error message .
    
 Copy code 

image.png

 This mistake is really a bit outrageous 
 The solution is also a simple batch , But I entered a misunderstanding , I wanted to pack and share , So I thought I was missing some files from my computer , Started to reconfigure python And reinstalled all third-party libraries , Later, I met a freshman here , What cannot be solved so far Bug:
** The lack of `Microsoft Visual C++ 2015 build tools**
 There are various solutions online , I try solutions almost every year , But in the end, it was fruitless , Whenever I forget this bug It always appears when . I installed. Microsoft Visual C++ 2015-2019、 One blogger mentioned the deletion ratio 13 Reinstall an updated version of 、 Download some provided by the boss 2015-2019 My mini bag , All tried , But every time you install paddlex This problem occurs all the time , As for how I installed it last time , I'll fill it with saliva and it's done , I didn't care , Because I don't know how to install paddlex There will be this mistake 
 Copy code 

image.png

As for the above bug Solutions for , I can only copy previously successfully installed paddlex==1.3.7 The bag of . There is also a solution with a high probability , Change the computer , The performance of thin and light book is really not very good ,python When I was engaged in deep learning, my computer was dying , So far, except in paddlepaddle Run outside the model on your server , Has completely given up treatment

python Third party Library requests And internal library urllib

 These are used to crawl simple web pages and use more crawler third-party libraries , Some of the more difficult may be to use Scrapy Frame to crawl or simulate the browser selenium Automated crawling . Basically some simple videos , Audio , picture , Both text libraries can be used to solve , But video still needs some technology , It's not about looking for videos online , Novices can learn , If a novice sees this about reptiles , Or take my advice : Most of the resources of novel websites are crawled , So many novel websites have almost no anti climbing technology , The best way to get started is to climb novels , The picture is basically the same , But there are few picture websites , Those websites without anti crawling technology are estimated to have collapsed . Audio is mainly troublesome to find , Needless to say, video search and integration are more troublesome , But it's not troublesome to learn to waste , There are online tutorials , But it is suggested to get familiar with the pictures of the novel before audio and video .
 Say more about requests and urllib The difference between! ,urllib The inner library is obvious , You can use it without downloading the package , But the disadvantage is that there are often text coding problems ,requests All aspects are good , Very few decoding methods are needed , Want text .text, want byte Just .content  It is very convenient , After all, it's a third-party library , If there were no better advantages than neku, it would have been remove 了 .
 Copy code 

About Scrapy The crawler frame

 Fast track Scrapy  Because the constitution of a competition mentioned this framework , I went to study , As for its advantages : modularization , If you fail, you can request again . technological process : According to their own understanding is their own perception : Some reptiles are used in urllib,request After waiting for the third-party library , It is obvious that there are various ways of writing these crawlers, from information query to information capture , And you have to use all kinds of request headers , Anti theft chain or something to avoid being crawled back ,Scrapy Formed a system and a set of processes , Make the crawling process more systematic . The flow chart is as follows , For review .
 Copy code 

image.png

Django frame

 A little too much , Just a little mention here , This framework is what I use to write the front and back ends ,Django Development is really convenient , especially ORM Docking database , This price comparison is really easy , Database migration has tasted the sweetness , But there are few online resources , It's time to reflect , Why? Django For so long, only when people mention python When the frame is, someone remembers , The mentioned web Back end , All people think of is SSM,Springboot,python Its advantage is to do data analysis and processing ,Java Mainly engaged in the back-end , So mention web Many people think of them for the first time .
 Copy code 

copyright notice
author[Pikachu who knows Baidu],Please bring the original link to reprint, thank you.
https://en.pythonmana.com/2022/02/202202012058030642.html

Random recommended