PymysqlIntroduced:A third-party tool library used in Python to connect to the MySQL database.Installation:by Command pip Install Pymysql installation, which can be installed through PIP3 in Python3. To connect to the MySQL database:Pre-Connection
UUID is a non-repeating random string created based on the Mac and the current time, etc.
import uuid# Generate a UUID from a host ID, sequence number, and the current time>>> uuid.uuid1()# Generate a UUID from the MD5 hash of a namespace UUID and
The del statement can delete the value at the bottom of the list, and all values following the deleted value in the table will move forward one subscript
Spam = [' A ', ' B ', ' C ', ' D ', ' E ']del spam[2]spamPrint display: [' A ', ' B ', ' D ',
Today I want to implement multi-threaded update asset information, so used to threading, but I need the return value of each thread, which requires me in threading. The thread is encapsulated on the basis of
def auto_asset (node): ret =
‘‘‘Describe365 days a year, on the 1th day of the capacity value of the base, recorded as 1.0.When studying well, the ability value increases n‰ compared to the day before, and when there is no learning, the ability value drops n‰ compared to the
Common data types for Python
Serial number
Data type
Defined
Format (example)
is variable
is ordered
1
NumberDigital
Python 3 supports int, float, bool, complex (plural).
1,one, One,
Recently, when writing code, found a problem, want to determine whether a string is a valid decimal, found that the string does not have a built-in method of judging decimals, and then wrote a judge whether the string is a decimal, you can determine
json.loads converting JSON data into Python-processed format (deserialization)The JSON must be double-quoted, the reason for this is different languages before the difference, in order to solve this problem, the provision of this formatConvert JSON
Interface Test Second wave, WebService interface come on, welcome to the small partners spit Groove ~This time take free internet domestic mobile phone number attribution to query Web Service WebService interface Do example, of course there are a
The problem of de-weight in python may be a simple question. For example a list:a = [1,3,2,9,5,3,1,5], how to remove duplicate elements, well, there is a high-end method: #方法一a = Set (a) A:1, 2, 3, 5, 9. Wow, good high-end, things are not so simple,
CollectionUnordered mutable sequence, where elements in a collection are not allowed to repeat, that is, each element is uniqueThe elements in the collection are sorted in ascending order1 #Create a collection2>>aset = Set ([0,2,4,5,7,2,3,5,9, 0])3>>
There are 4 scopes in Python:
name
Introduction
L
Local scope, variables defined in the function;
E
Enclosing, the local scope of the nested parent function, which is the local
In Python, we have two important concepts: class and instanceFor example: We in real life is a class, instance is specific to a certain man (Zhang San, John Doe, etc.)1. Class: Define the Human classclass People (object):p2. Example: Creating an
1. Definition: Where the variables in the function are valued;2. The variable name in a function is a local variable except that it is declared as a global variable or a local variable;3. The scope resolution principle of variables: the LEGB
OS Module Brief Introduction:It is a python system-programmed operating module that can handle files and directories. For example, to find files or directories, to a large number of paths and file processing.Common methods of Operation:Os.name:
" "1. Start with a canvas 2. Random Turtle and Fish position 3. Move" "ImportRandom as R list_x= [0,10]list_y= [0,10]classTurtle:def __init__(self):#Initial physical Strengthself.power=100#Initial Positionself.x = R.randint
1. Ternary operationThe IF condition is the result of the if condition that the else condition is not establishedFor example:A=20b=10C=a if a>b else bPrint (c)2. Namespaces
Global namespaces: The space created to store "variable
Problem: Using Python to match strings between two strings in a regular wayWorkaround: Using the FindAll of the RE module, note that Re.match is only matched from the beginningMethod:Import''= Re.findall (R' (. *) ', html_str)print(local[0]) #' var,
Cookies, which are data stored on the user's local terminal (usually encrypted) by certain websites in order to identify users and perform session tracking.For example, some sites need to log in to access a page, before you log in, you want to crawl
This article mainly describes the Python meta-class instance resolution, the main task of this article is to give you a thorough understanding of what is a meta-class, the need for friends can refer to the next
Uncle Turtle invented Python and then
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