#-*-Coding:utf-8-*-# import SQLite driver:>>> Import Sqlite3# Connect to the SQLite database# Database file is test.db# If the file does not exist, it is automatically created in the current directory:>>> conn = sqlite3.connect (' test.db ')# Create
Generate Activation Code#!/usr/bin/env Python#encoding:utf-8#author:seanimport Stringimport random# The characters and numbers in the Activation Code field = String.letters + string.digits# get four letters and numbers in a random combination def
1.1 Reading the configuration file-read (filename) reads INI file contents directly-sections () gets all the sections and returns as a list-options (section) gets all the option of the section-items (section) gets all the key-value pairs of the
Pythona simple calculation in(1) Basic subtraction>>> 2 + 24>>> 50-5*620>>> (50-5*6)/45.0>>> 8/5 1.6(2) Division will always return a floating-point number, want to return an integer, need to use "//" to represent (floor Division), in addition, you
#!/usr/bin/pythonfrom subprocess Import Popen,pipedef getifconfig (): Data = Popen ([' ifconfig '], stdout=pipe) new_dat A = Data.stdout.read (). Split (' \ n ') return [i-I in New_data if I]def getip (data): dic = {} for I in data: Devname =
One. Open Filef = open ("DB", "R", encoding= "UTF8")
R: Read-only
W: Write only, the file will be emptied first
A: Append
X: If file exists, then error, otherwise, create file and write only
B: The above parameters can be
#今天来学习一下函数, function# when defining a function, the function will not be executed, only the function will execute if it is called.## Defining functions# # 1, def is the keyword to create a function, create a function# # 2, Name of function# # 3, ()#
Regular ExpressionsThe approximate matching process for regular expressions is to take out the expression and compare the characters in the text, and if each character matches, the match succeeds; If a match is unsuccessful, the match fails.The RE
# Factory function Def factory (X): def item (Y): print "x**y:%s" % (x**y) return x**y return item def head (W): print "x+w:%s" % (x+w) def main (): f = Factory (x=2) #实例化, equivalent to class i = f (
#__Author: "Skiler Hao"#date: 2017/2/15 11:06"""Mainly the use of test and practice time modulesTime consists of string format, timestamp, and structured time primitiveWed Feb 15 11:40:23 20171463846400.0Time.struct_time (tm_year=2017, tm_mon=2,
Due to certain requirements, it is necessary to send a Daily mail to the relevant personnel, including the day before the Zabbix monitoring graphics, log on daily and manually sent words is very troublesome.A simple repetition of the work to the
1. View Python-installed package version information: PIP listThe original paste, there is empty perfect. http://yangzb.iteye.com/blog/18247612.Python files are executed quickly.The header file executes the Python file quickly, if you use it python
OutlineVariables and typesCommon string HandlingConditional judgmentLoop controlFunctionVariable and type basic variable typesFor Python all objects are class containers that inherit from object:Integer print (type (1234)) lists Print (Type ([1, 2,
Scenario: The latest to start learning Python, previously because a project has been exposed to Python language, but then only on the project platform with the help of the Python tool language. Taking advantage of the short leisure time of winter
The super () function works according to the two parameters that are passed in:
The class name passed in by the first parameter determines where in the MRO is currently located. MRO (Method Resolution Order);
The current MRO list is determined by
The Magic method of Python is those predefined images in Python.
__XXX__Type of function.
The biggest advantage of using Python's Magic method is that Python provides a simple way for objects to behave like built-in types.
__str__
Preface
We all know that it's very easy to learn Django, so you can get started with almost no effort. Configure a URL, give it a function to process it, return to response, almost nothing difficult to understand the place.
Write more, some
Python Map
Map maps a function to all elements of an input list. Map specifications are: Map (function_to_apply, list_of_inputs)Most of the time, we need to pass all the elements in the list to a function and collect the output. For example:
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