• Introduction to the difference between add and update in Python set


    The set set is a set of unordered non repeating elements ? 1 2 3 4 set([‘hello’,’hello’,’hi’]) # {‘hello’, ‘hi’} set(‘hello hello hi’) # {‘ ‘, ‘e’, ‘h’, ‘i’, ‘l’, ‘o’} The difference between set. Add() and set. Update() ? 1 2 3 4 5 6 7 8 9 myset1 = set() myset1.add(‘hello’) #{‘hello’} myset1.update(‘world’) […]

  • Python implementation of OCR recognition pyteseract case explanation


    Python implementation of OCR recognition: pytesseract Python often uses pyteseract for character recognition on pictures, that is, OCR recognition. The complete code is relatively simple, as long as the following line, but it is easy to make mistakes in the environment configuration in actual use. from PIL import Image import pytesseract text = pytesseract.image_to_string(Image.open(‘/Users/alice/Documents/Develop/PythonCode/textinphoto.PNG’)) print(text) […]

  • Ideas and methods of formatting output documents in Python database


    problem If the document format is uniform, can I format and output Doc / MD documents through Python? It can be done in code. Try not to do it manually thinking First of all, the data has been recorded into the database. You need Python to be able to read the database. You can use […]

  • Introduction to Python OS module and fnmatch module


    1、 First introduce the OS module ? 1 2 3 4 5 6 7 8 9 10 import os   print(os.getcwd()) # E:\python\test\python_models #Get current directory     print(os.listdir(“.”)) # [‘oop.py’, ‘python_argparse.py’, ‘python_click.py’, ‘python_os.py’, ‘python_re.py’, ‘python_requests.py’, ‘xx.py’, ‘__init__.py’] #Lists all files and folders in the specified directory, and returns a list 1. Introduction to splitting […]

  • Python implements the multitasking version of UDP chat


    In this article, an example is given to share with you the implementation of the multitasking version of UDP chat in Python for your reference. The specific contents are as follows 1、 Case example 2、 Case description 1. Write a program with 2 threads.2. Thread 1 is used to receive data and display it.3. Thread […]

  • Seven Python code review tools recommended


    althoughPythonLanguage is one of the most flexible development languages at present, but developers often abuse its flexibility and even violate relevant standards. So PythoncodeThe following common quality problems often occur: Some unused modules have been imported Function is missing arguments in various calls The appropriate format indentation is missing Missing appropriate spaces before and after […]

  • Implementation of format binary conversion and deletion of binary prefix in Python


    10 decimal, hexadecimal, octal and binary conversion: (#: reserved hexadecimal prefix) For those with hexadecimal prefix, such as “0x” “0o” “0b”, you can directly add ‘x’ and ‘o’ ‘B’ to delete them: Other tips: format(num, “,”) Fast division of millennia How many digits are the numbers to complete, ^ center > right alignment < left […]

  • Introduction to Python variable scope and list


    Variable scope Variables are limited by scope Classification: by scope Global: defined outside the function Local: defined inside a function Scope of variable Global variable: valid in the whole global scope Global variables can be used locally (that is, variables defined outside the function can be accessed inside the function) Local variables can be used […]

  • The meaning and usage of Python variance test


    explain 1. Variance test is used to compare the samples of two or more variable data to determine whether the difference between them is simple and random or due to significant statistical differences between processes. 2. The independent variable x is a discrete data, and the independent variable y is a continuous data (x can […]

  • Detailed explanation of Python using consumer for service discovery example


    preface The previous chapter talked about some advantages and disadvantages of microservices, and how to do it 1、 Target 2、 Use steps 1. Install consumer We can directly use the binaries provided by the official for installation and deployment. The official website address is https://www.consul.io/downloads After downloading, it is an executable file, which can be […]

  • Python multithreading method example of multitasking


    catalogue 1 multithreading to achieve multitasking 1.1 what is a thread? 1.2 a program to achieve multitasking method one point three   How to create multithreading 1.3.1   Create threading.thread object 1.3.2   Inherit threading.thread and override run one point four   When does the thread start and end one point five   Thread’s join() […]

  • Multiple operations for each number in the python square list


    map map(function,iterable) x = [1,2,3,4,5] def square(num): return num*num print(list(map(square,x))) #output:[1, 4, 9, 16, 25] lambda lambda x: x = [1,2,3,4,5] print(list(map(lambda num:num*num, x))) #output:[1, 4, 9, 16, 25] list comprehensions [funtion for item in iterable] print([ num*num for num in [1,2,3,4,5]]) #output:[1, 4, 9, 16, 25] Supplement: several methods of finding the square root […]