I. Extension methods for classes 1. Static methodsSyntax: @staticmethod, a static method cannot access a public property and cannot access a class. Can be called directly after instantiation, and in the method can be invoked by self. Invokes an
Mode one: function1 def fabs (n): 2 A, b = 0, 13while B N:4 print(b, end=" /c13>)5 A, B = B, A +b67 fabs (1000)View CodeWay two: List1 result = [0, 1]23def fabs (n):4 while N-result[-1] > Result[-2]:5
There are 6 kinds of caching methods available in Django:
Development and commissioning
Memory
File
Database
Memcache cache (python-memcached module)
Memcache cache (PYLIBMC module)
1. Development and Commissioning#
Python's Small combat assignment IPFirst, Background introductionBecause of the work needs, the management of the company's global computer room IP, other departments to extract work orders from my side to help assign some ping IP to use. So there
Writing the Login interface
Enter User name password
Show welcome message after successful authentication
Three-time error after locking
#!/usr/bin/env python#_*_ Coding:utf8
Process-oriented: functional, C program and other object-oriented programming: C++,java,python Class and Object: Class: Is the abstraction of things, such as human, Ball object: Is an example of the class, such as football, basketball example shows:
Python's singleton pattern is that an instance of a class can be created only once from the beginning. Application scenarios such as database connection pooling.#!/usr/bin/env python# Coding=utf-8classFoo (Object): Instance=None def __init__ (self,
Python Standard exceptionException Name DescriptionBaseexception base class for all exceptionsSystemexit Interpreter Request ExitKeyboardinterrupt user interrupt execution (usually input ^c)Exception base class for general errorsStopiteration
Note: Root privileges are requiredTo view the Python version:Python--version1. Download Python-2.7.12wget https://www.python.org/ftp/python/2.7.12/Python-2.7.12.tgz2. UnzipTar zxvf python-2.7.12.tgz3. Change the working directoryCD Python-2.7.124.
| Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.The previous part has already compiled a simple Web service for TSSS, and the basic template of the Web page is also written, which starts
Today's learning Record:Variable ReplayCoding issuesASCII code: and the corresponding relationship between the decimal, decimal into binary, and then the computer can be recognized;Unicode: Unified encoding, but too long, two bytesUTF-8: Changeable
The first thing to make clear before installing pyquery is that Easyinstall is a Python package manager, similar to node's NPM, for installing Python's expansion pack, which installs packages in a *.egg way.To install the PQ you need to go through
1 Viewing the Python versionubuntu16.04 LTS system installed by default python2.7.12 and python3.5.2, they can be found under the/usr/bin/, the default python2.7.81) Get the Python version number in Python and use the command to get the Python
classA:defBar (self):Print("BAR") self.f1 ()classB (A):defF1 (self):Print("B")classC:defF1 (self):Print("C")classD (c,b):Passobj=D () Obj.bar ()#classes A, B, C, D are created;#D inherited the C and B,b inherited the a,d within nothing to do,
First python refers to AES encryption from Crypto.cipher Import AESNeed to install the Crypto module, you can use the Easy_install installation will automatically go to the official website for the search installationWhere code example:AES
Operation of the list1. Modification of the list>>>name['Frank','Lee', 2, ['Andy','Troy']]>>> Name[0] ="Frank Bian">>>name['Frank Bian','Lee', 2, ['Andy','Troy']]2. Inserting a list>>>name['Frank Bian','Lee', 2, ['Andy','Troy']]>>> Name.insert
Basic idea of inserting sort:
Each step inserts a record to be sorted by the size of its key value into the appropriate position in the previously sorted file until all is inserted.
Cases:
arr = [49,38,04,97,76,13,27,49,55,65], from the 2nd
Python data type --- list 3, python Data Type
1. determine whether an element exists in the list: "in" Usage
List = ['frank', 99, 'is ', 78, 4, 'smart'] print (99 in list) print (9 in list) # running result TrueFalse
2. Statistics on the number of
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