Python AES encryption module Usage Analysis, pythonaes encryption module
This example describes the usage of the Python AES encryption module. We will share this with you for your reference. The details are as follows:
AES is a new encryption
Python's third-party module typically comes with setup.py files, and in a Windows environment, we only need to use the following command at the command line to automate the installationPython setup.py InstallThe error message "Importerror:no module named Setuptools" may appear during installation because Python does not have the Setuptools
1.1Mounting Module1.1.1installing third-party modulesThe third-party library will be Python official pypi.python.org website registration, to install a third-party library, you must first know the name of the library, you can search on the official website or PyPI , such as Pillow name called PillowPip Install Pillow1.1.2Module Search Pathwhen we try to load a module, P
dt2 = Dt-timedelta (days= 1) #昨天dt3 = dt + Timedelta (days=1) #明天delta_obj = Dt3-dtprint type (delta_obj), Delta_obj#5. Tzinfo Time Zone class#! /usr/bin/python# coding=utf-8from datetime import datetime, Tzinfo,timedelta "" "Tzinfo is a class about time zone information Tzinfo is an abstract class, So cannot be instantiated directly "" "Class UTC (Tzinfo):" "" "" "" "" "" def __init__ (self,offset = 0): self._offset = offset def Utcoffse
Http://blog.csdn.net/pipisorryPython's pickle module implements basic data sequence and deserialization. Through the serialization of the Pickle module we are able to save the object information running in the program to a file, to store it permanently, and through the Pickle module's deserialization, we are able to create from the file the last object saved by the program.Basic interface:Pickle.dump (obj,
(Stderr_res1.decode (' GBK ')) #windows默认的是gbk编码的, so the decoding also uses GBK#print Result: ' Taskliasdfsadfst ' is not an internal or external command, nor is it a running program#or batch file. #print (stderr_res1) #第一次从管道中取走, followed by empty#print (stderr_res2)#print (STDERR_RES3)#Import Time#Time.sleep (+)Second, sys moduleImportSYS#Sys.path: Gets a collection of strings for the specified module search path, which can be placed in a given pa
The Getpass module of the Python Module FoundationThe Getpass module provides portable password input, including the following two functions:1. Getpass.getpass ()2. Getpass.getuser () Getpass.getpass ([prompt[, Stream]])Prompts the user to enter a password, the parameter prompt prompts the user to start the input, def
Python's logging module provides a common logging system, and skilled use of the logging module makes it easy for developers to develop third-party modules or their own Python applications.Python uses the logging module to log logs involving four main classes:Logger: Provides an interface that the application can use d
and deserializes a serialized string from a fileWith open ("Test1.txt","RB") as F:Print(Pickle.load (f))#The result is: {' K1 ': ' v1 ', ' K2 ': ' V2 '}#pickle.dumps () converts data into a string that is recognized by all programming languages in a special formPICKLE_STR1 =pickle.dumps (data)Print(PICKLE_STR1)#The result is: B ' \x80\x03}q\x00 (x\x02\x00\x00\x00k1q\x01x\x02\x00\x00\x00v1q\x02x\x02\x00\x00\x00k2q\x03x\x02\x00\x00 \x00v2q\x04u. '#Pickle.loads deserializing a serialized stringPIC
backtracking.Considerations for recursion:1. Recursion must have a definite end condition.2. Each time a deeper level of recursion is reached, the problem size should be reduced compared to the previous recursion.3. recursive efficiency is not high, in Python, too many recursive layers can cause stack overflow. Recursive applications:Two-part methodModules: self-with modules, their own modules, third-party modules.How to use the
1. OS module: Provides an interface for invoking the operating systemOS.GETCWD () Gets the current working directory, which is the directory path of the current Python script work os.chdir ("DirName") changes the current script working directory, which is equivalent to the shell Cdos.curdir return current directory: ('. ') os.pardir Gets the parent directory string name of the current directory: (' ... '
Use python's logging module and pythonlogging Module
I. Starting from a use case
To develop a log system, you must output logs to the console and write log files.
Python code
Import logging
# Create a logger
Logger = logging. getLogger ('mylogger ')
Logger. setLevel (logging. DEBUG)
# Create a handler for writing log files
Fh = logging. FileHandler ('
Python Flask module and pythonflask Module
The module is a file containing response text, which contains the dynamic part represented by a space variable. The specific value is only known in the request context. Replace the variable with the actual value and return the final response string. This process is called rend
Description of common functions of the Python OS module, and functions of the pythonos Module
The OS module in the Python standard library contains common operating system functions. This module is especially important if you want
Installing the Nmap module:Pip Install Python_nmaNmap Module Description:Python-nmap is a Python library that helps to use the Nmap port scanner. It allows easy manipulation of NMAP scan results and will be a perfect choice for tools and reports from system administrators who need to automate the scanning task. It also supports Nmap script output.Nmap Module clas
Reference Blog: http://blog.csdn.net/SeeTheWorld518/article/details/48314501Http://www.jb51.net/article/49325.htm
Functions commonly used in the time module
Function
Function
Time.time ()
Get time stamp
Time.localtime ()
Get the time element ancestor and convert the timestamp to the time element ancestor
Time.gmtime ()
Get the time element ancestor and convert t
(socket.socket (socket.af_inet,socket. SOCK_STREAM) , S.connect ())2. send data and receive data after connection (S.sendall (), S.RECV ())3. when the transfer is complete, close the socket (S.close ())4. Example 1:Service side:[Email protected] python]# vim socket12.py#!/bin/env python#!-*-Coding:utf-8-*-Import socketS=socket.socket ()Host=socket.gethostname ()port=1234S.bind ((Host,port))S.listen (5)Whil
pyrun_simplestring (s), the function of everyone to see what is used to do it. Using this function allows you to write some python directly in the parameters, and then the Python environment calls this function to complete the Python statement you wrote. For example pyrun_simplestring ("Import Tree"), using this statement, you can use
number\d-is the opposite of \d.\s--take any whitespace character\s---In contrast to \s\w-take any letters and numbers\w---In contrast to \wAnd when using \w these symbols, consider that the re itself is a miniature language, and when we pass data such as \b to the Python interpreter, Python will translate it over and over again to the re. After the translation of the number has lost its original meaning, s
ignored. formatting strings that may be used in the format parameter:%(name) s Logger's name%(Levelno) s log level in digital form%(levelname) s log level in text form%(pathname) s The full pathname of the module that invokes the log output function, possibly without%(filename) s The file name of the module that invokes the log output function%module Name of the
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.