Members of the class
Field
Normal fieldSave in object, execute only through object access
Static fieldsstored in the class, execution can be accessed through the class or through the object
Method
Today, a question suddenly comes to mind: will you immediately write out the sorting algorithm for the heap platoon, the fast platoon, etc., and not make a logical mistake? I said: No, at least you need to think about it, and it may take time to
Today, I saw the Marco Linux operation in the public number, pushed an article, using Python to send mail cases, so the experiment, success, speed record.Using the python3.x version, install the Zmail module;Pip Install ZmailThis time use QQ mailbox
Installing and running the interactive interpreterIn the vast majority of Linux and UNIX system installations (including Mac OS X), the Python interpreter already exists. We can verify by entering the Python command at the prompt (author Environment
Flask How to use logging:1. Initialize Flask Application ExampleUsing logger in flask requires initializing an flask applicationApp = Flask (__name__)2. Call LoggerCalling the Logger method directlyApp.logger.info ("My first Logging")The log at info
The meaning of installing two versions
Verifying your code's compatibility with versions
Some of the source code downloaded online can only be run in Python2 or Python3.
installation process logging 1. Go to Python's website to
no matter how tactical change, don't forget the strategy. In the earlier days, White has used getopt to get command-line tools.However, in order to complete a seemingly simple, actually have N more than the logic of the case is a bit
A shortcut key to useCTRL +? Quick NotesCtrl+d Quick CopyTwo operatorsThe first contact requires special note: = is greater than equals;! = is not equal to; = = equals1) and, or useif and score:print(' good results ')if' man ' or' woman ':print('
Function-If you want to reuse the same or very similar functions, write a function.-function uses the DEF keyword declaration to return a value with the return keyworddef my_function(x, y, z=1.5): if z > 1: return z * (x + y) else:
Let's say python can simply handle +-/, parentheses cannot be processed. Practice processing. Practice the regular.Some of the internet does not handle the negative sign well, as follows. Temporary unhandled parentheses missing between numbersand
Looping statementsOne of the loops in Python:For....in ... Cycle:Print the elements in the list or tuple in turn:# Looping Statements for...inclassmates=['name1','name2',' name3','name4']for in Classmates: print(classmate)The results of the
variable naming rules:
The first character must be a letter in the alphabet or an underscore ' _ '.
The other parts of the identifier are composed of letters, numbers, and underscores.
Identifiers are case sensitive.
It can't be
This section learns to use Sklearn for voting classification, see a specific example, the dataset uses the Iris DataSet, using only the sepal width and petal length two dimension features, Category we also only use two categories: Iris-versicolor
When we apply different preprocessing techniques, such as the standardization of features and the analysis of data principal components, we need to reuse certain parameters, such as standardizing the training set and normalizing the test set (both
JSON (JavaScript Object Notation) is a lightweight data interchange format that makes JSON an ideal data exchange language with a concise and clear hierarchy. Easy for people to read and write, but also easy to machine analysis and generation, and
defDel_blank_line (filename):#clear File blank line """Clear blank line of file:p Aram FileName: file name: Return:true succeeded; False failed""" Try: With open (filename,"r+", encoding="Utf-8") as Infp:lines= Infp.readlines ()#read the
Dynamic addition of attributes and methods for python classes and instances, and dynamic addition of python instances
From types import MethodType# Python is a dynamic language, so it can dynamically add attributes and methods to classes and
Python ddt achieves data-driven, and pythonddt implements data
Ddt is a third-party module and must be installed. pip install ddt
DDT contains the class decorator ddt and two methods decorator data (directly input the test data)
Generally, data in
Python learning notes-use pip to install the module, pythonpip
We often need to install various modules when using Python, while pip is a very powerful module Installation tool. Similar to linux Yum, It can automatically resolve dependencies when
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