- When we run some automated programs with Python on a regular basis, there will be situations where the program crashes. At this point, if you are not personally in front of your computer
- The built-in argparse module makes it very easy to script friendly command-line arguments, and it automatically generates a help manual that throws clear error messages when the user passes invalid arguments to the program
- Usually we use Google Chrome's developer tools (F12) to find a web request, then record the url, headers, cookies, user-agent, request parameters, etc. inside the web request, and then, use requests to simulate the request sent by the browser.
- Suppose we have two or more dict and we want to merge them all into a single dict with a unique key
- The first time I used requirements.txt, I was in a virtual environment, and I exported the project's dependencies to a txt file using pip freeze > requirements.txt, and then uploaded it to GitHub so that others could use the project with pip install -r re
- py-spy is a performance monitor, analyzer for Python programs. It allows you to visualize the time spent by your Python program without having to restart the program or modify the code in any way.
- If we execute this program, the program will hang at sleep, and then we can use the ps command to get the corresponding pid. we want all kinds of tools to use this pid directly, without modifying or restarting the program itself, to get the relevant calls
- Cython, which many of you have probably heard of, is used to speed up Python. If you've ever programmed in Python with the following in mind, then Cython is perfect for you.
- 1.dispach Python naturally supports polymorphism, but using dispatch can make your code easier to read. Installation. pip install multipledispatch Use. >>> from multipledispatch import dispatch
- The last task of the list code snippet, if given a list and mapping it to a dictionary, that is, we want to convert our list to a dictionary with numeric keys