Category:Python

  • Python implements the method of obtaining the current login user information

    Time:2019-8-24

    In this paper, an example is given to illustrate how Python achieves the information of the current logged-in user. Share for your reference, as follows: In Linux environment, Python is more used as a tool language to replace SHELL. In fact, there are many commands in Linux that are extended by python. I want to […]

  • Python [Function]

    Time:2019-8-24

    function   Built-in functionprint() input() len() type() … print(‘Hello World’) Functional parameters   Define functiondef greet(name):Print (name +’good morning’)   return first lineDef means definition.Green is the name of the function.Then match a parenthesis with a colon. The name in parentheses is a parameter (the parameter name is also taken by oneself). Second lineThe next line […]

  • Detailed Operations of QTabWidget in pyqt5

    Time:2019-8-23

    Firstly, the interface file processed by designer (converted into py) is pasted below. # -*- coding: utf-8 -*- # Form implementation generated from reading ui file ‘TabWidget.ui’ # # Created by: PyQt5 UI code generator 5.12.1 # # WARNING! All changes made in this file will be lost! from PyQt5 import QtCore, QtGui, QtWidgets class […]

  • Maintenance of cookie pool

    Time:2019-8-23

      Storage form: Stored in redis, “spider_name: username – password”: cookie Establish py file and include method: Initcookies () initializes cookies for all accounts, logs in all account pairs to get cookies and saves them in redis Update_cookie (spider_name, username, password) # retrieves the cookies corresponding to the account and stores them in redis Remove_cookie […]

  • A simple example of Python parsing XML

    Time:2019-8-22

    This paper illustrates python‘s method of parsing xml. Share for your reference, as follows: XML is another commonly used carrier format for data exchange besides json. For some fixed data, it can be saved directly in xml, and it can also avoid the trouble of querying in the database. And read small files directly, the […]

  • Python Review Notes 01

    Time:2019-8-22

    (1) Computer Common Sense Computer: Hardware (Operator, Controller, Memory, Input Device, Output Device) Software (System Software, Application Software)   Binary Integer storage Document list Bit Conversion 1Byte = 8bit 1KB = 1024Byte 1MB = 1024KB 1GB = 1024MB …                 Computer Editing Cheng Language machine language assembly language […]

  • Method of displaying coordinates with pyqt5 mobile mouse

    Time:2019-8-21

    As follows: # -*- coding: utf-8 -*- import sys from PyQt5.QtWidgets import (QApplication, QMainWindow, QLabel) from PyQt5.QtCore import Qt class AppDemo(QMainWindow): def __init__(self): super(AppDemo, self).__init__() self.init_ui() def init_ui(self): self.resize(300, 200) self.setWindowTitle(‘666’) self.label = QLabel(self) self.label.setAlignment(Qt.AlignCenter) Self. label. setText (‘Liushenhua Dew’) self.label.setGeometry(5, 5, 145, 185) self.label.setMouseTracking(True) self.label_mouse_x = QLabel(self) self.label_mouse_x.setGeometry(155, 5, 80, 30) self.label_mouse_x.setText(‘x’) self.label_mouse_x.setMouseTracking(True) self.label_mouse_y […]

  • Scapy-redis Data Reduplication and Distributed Framework

    Time:2019-8-21

      Data Reduplication Generating fingerprint: using hashlib’s SHA1 to encrypt request body, request URL and request method, and return a 40-bit 16-digit string called fingerprint fp = hashlib.sha1() fp.update(to_bytes(request.method)) fp.update(to_bytes(canonicalize_url(request.url))) fp.update(request.body or b”) return fp.hexdigest() Entry: (Queue de-duplicates requests objects, Zset de-duplicates fingerprints) If the request needs to be filtered and the fingerprint of the […]

  • Solve the problem of flickering back after opening the console of EXE file packaged and published by pyinstaller

    Time:2019-8-20

    Solution steps: 1. Open a CMD first 2. CD to your EXE file directory 3. Input  .\***.exe The above article solves the problem that the EXE file of pyinstaller packages and publishes flickers off the console, which is all the content shared by the editor. I hope to give you a reference, and I hope […]

  • Nana sauce 1999

    Time:2019-8-20

    There are still some confusions about the understanding of ornaments, lambda, duck types and magic functions. Take advantage of the weekend time to warm up, hurry to learn the relevant knowledge by yourself. 1. What are the decorations? Many beginners only have a superficial understanding of the concept and form of decoration when they touch […]

  • The Shortest Path Problem of Dijkstra Algorithms Implemented by Python

    Time:2019-8-19

    Dijkstra algorithm is mainly aimed at directed graph without negative value, which solves the shortest path algorithm from a single starting point to other vertices. 1 Algorithmic Principle Dijkstra algorithm is a shortest path algorithm generated in the order of increasing path length. The following figure is a weighted digraph, which is used as experimental […]

  • Python iterator, error, exception handling

    Time:2019-8-19

      iterator Iterators can be used to traverse strings, lists, tuples, collections, dictionaries. myString=”hello” MyIter = ITER (myString) # # ITER () function can obtain an iterator of the set of elements For I in myIter: # traverse each character print(i) myList=[1,2,3,4] myIter=iter(myList) For I in myIter: # traverse lists, tuples, collections print(i) MySet={“name”: “Zhang […]