Logging moduleMany programs have logging requirements, and the log contains information that has normal program access logs, there may be errors, warnings and other information output, Python's logging module provides a standard log interface, you
UrlEncode and UrlDecode
When the URL contains Chinese or the parameter contains Chinese, the Chinese or special characters (/, &) need to be encoded for conversion.The essence of UrlEncode: Convert the string to GBK encoding, and then replace
The Hashlib module is used to encrypt related operations, replacing the MD5 module and the SHA module in 3.x, mainly providing SHA1, SHA224, SHA256, SHA384, SHA512, MD5 algorithm import hashlib m = Hashlib.md5 () m . Update (b "Hello") M.update (b
The content here is just a few of the things I've learned from reading Python's high-performance programming for a better understanding of the python mechanism. I am not currently engaged in computational-intensive work: artificial Intelligence,
Ternary operatorsTernary operators are often referred to as conditional expressions in Python, which are based on the condition of True (TRUE)/False (false), and have ternary operations above Python 2.4.Here is a pseudo-code and an example:Pseudo
1, print, direct printing, relatively simple and rude in the code directly input print+ need to output the results, according to the printed content to judge2, assert assertion, very convenient, testers often write automated use cases when using
L1 = [One, 2, 3, 2, 4, one, 3] go heavy and keep the original order# Collection Method L2 = list (set (L1)) L2.sort (Key# sorted by L1 index print(L2)# list l3 = [] for in L1: if not in L3: l3.append (item)print(L3)AnswerL4 = [ {"name"
Example: Xiao Ming transfer Pension a pot of goldfish 5 times for sale: The 1th time sell all the half plus 1/2, the 2nd time to sell the remaining One-third plus 1/3, 3rd sell the remaining One-fourth plus 1/4; Sell the remaining one-fifth plus
This article is a follow-up of the video-to-character animation-python-60 line code, and if interested, see it first.
1. Speed optimizationIt's a bit too painful to wait a minute for each play.So you can use the Pickle module to save the
Definition of the zip () function
Combine elements from multiple iterators in a parameter into a new iterator;
return: returns a Zip object whose inner elements are tuples, which can be converted to lists or tuples;
Incoming
1. Formatted character with%s,%d,%f floating-point number%s stands for formatted string, S is string meaningmsg = ' My name is%s '% "xiaoxing"Print (msg)Operation Result:My name is xiaoxing%d represents integer data intmsg = ' My name is%s,age:%d '%
25, there are the following variables, please implement the required functionsTu= ("Alex", [11,22,{"K1": ' V1 ', "K2": ["Age", "name"], "K3":(11,22,33)},44])A. Characteristics of Ganso: tuples have all the attributes of a list, but the elements of a
Python: Underlying data type---bytesBecause the Python string type is str , in memory, in Unicode, one character corresponds to a number of bytes. If you want to transfer on a network, or save to disk, you need to turn it str into bytes bytes
Each script has its own expertise.There is a time to achieve a work, the use of Shell,php,python look at the file type, inconvenient handover, looking also more trouble .It is also necessary to reduce the number of file types.Scenario encountered:
The Subprocess module is a module introduced by Python starting with version 2.4. It is mainly used to replace some old module methods, such as Os.system, os.spawn*, os.popen*, commands.* and so on. subprocess executes the external instruction
Because it's important to drink water every day.Directory structure:├─bin││start.py│││└─__pycache__│start.cpython-36.pyc│├─core││src.py│││└─__pycache__│src.cpython-36.pyc│└─logAccess.logCode content:start.py1 """2 Description:3 Author:nod4 Date:5
1. ClientImport sockets = Socket.socket (socket.af_inet,socket. SOCK_STREAM) #建立TCP连接S.connect (' 192.168.1.109 ', 1111) #连接服务器, requires the server's address and portPrint (' This is the client! ‘)While True: t = input ()
Below for you to share a python through the logging write log to file and console instances, has a good reference value, I hope to be helpful. Come and see it together.
As shown below:
Import Logging # Creates a logger logger = Logging.getlogger ('
This article mainly introduces the Jpype implementation in Python call Java instance, small series feel very good, now share to everyone, also give you a reference. Let's take a look at it with a little knitting.
I. Brief introduction of Jpype
What
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.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service