1. One line of code realizes the sum of 1--100
Use the sum() function to sum:
2. How to modify global variables inside a function
Use global to modify global variables:
3. List 5 python standard libraries
- os: provides many functions associated with the operating system;
- sys: usually used for command line parameters;
- re: regular match;
- math: mathematical operations;
- datetime: handle datetime;
4. How to delete keys and merge two dictionaries
del and update methods:
5. Talk about Python's GIL
GIL is python's global interpreter lock. If there are multiple threads running in the same process, one thread will occupy the python interpreter when running a python program (adding a lock is GIL), so that other threads in the process cannot Run, and other threads can only run after this thread finishes running. If a time-consuming operation is encountered while the thread is running, the interpreter lock is unlocked to allow other threads to run. Therefore, in multithreading, the running of threads is still sequential.