How to make a crashed Python program restart itself on Windows

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

python argparse tutorial

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

convert Curl to Python requests code

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.

Merge two or more dict

Suppose we have two or more dict and we want to merge them all into a single dict with a unique key

pip-tools manages python environment dependencies

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: excellent performance monitoring for Python programs

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.

pystack-debugger use

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

What is Cython? Why is there Cython?

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.

Seven nice python decorators

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
  • Views: 113
  • Keywords: python,

Mapping lists to dictionaries

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