#-*-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
1 Oop object Worldview-oop is the language of human cognition closest to real life
All Business Objects
The object has the law of motion and the internal state
objects can be called to each other
2. Object-oriented
BasisCharacter encoding
Character: The character is a unit of information, it is a general term for all kinds of words and symbols, including national text, punctuation, graphic symbols, numbers, etc.
Character set: The character
1. the variable name with an asterisk (*) will hold all the unnamed variable parameters, cannot store dict, or error.Such as:1 defMultiple (ARG, *args):2 Print "ARG:", Arg3 #print variable length parameters4 forValueinchargs:5
#_ *_coding:utf-8_*_#!/usr/bin/env pythonThe use of #======================== "=========================# def foo (x, y):# Print (x)# Print (y)#按位置传值# foo (ON)# foo (2,1)#按关键字传值# foo (y=2,x=1)#注意问题一: For the same form factor, you can pass values by
List function:Function: Convert character to list, example:List Basic functions:1. Element Assignment , example:Note: by list[0]= ' Hel ', if there is a value in the original position, it will overwrite the original.2. Shard Operations1) Display
Tag: Action end string Operation Pytho Strip intercept Mat string nbsp1. Two types of string formattingString%s number%dExample Name= ' I am%s '% ' FKK 'Print (name)' I am FKK '>>> name= ' I am%s,age%d '% (' daoxin ', +) >>> name ' I am daoxin,age 13
First, the dictionaryA dictionary in Python is not a sequence, but rather a mapping; it is stored by key instead of by location. The dictionary is mutable. 1. Dictionary Mapping OperationsUsing the {} definition dictionary to store data in key:value
This article mainly introduces the Python data structure of the queue implementation of the relevant data, the need for friends can refer to the following
Python queue
Queue queues are a first-in, in-out (FIFO) data type, and new elements are added
Three ways to iterate through the list of numbers and values:
Recently learn the language of Python, feel its work efficiency has a great improvement, special on Valentine's Day wrote this blog, the following nonsense say, direct sticker code
#!
Preface
Python has added a new string formatting method to version 2.6: str.format() . Its basic syntax is to replace the previous% with {} and:.
Placeholder syntax when formatting:
Replacement_field:: = "{" [Field_name] ["!" conversion] [":"
First, version comparison
The first thing to say is that the Python version is currently divided into two major categories:
Python 2.x version, called Python2: is the most widely used, such as Python 2.7.3.
Python 3.x version, called Python3: is
Objective
Adorners are often used in program development of a function, but also the basic knowledge of Python language development, if you can use the appropriate decorator in the program, not only can improve the development efficiency, but also
When we are writing multi-threaded program, we often encounter two types of variables.
One is a global variable, and multiple threads are shared. In order to avoid the confusion, we have mentioned in the preceding to add lock.
One is a
background
Mid-Autumn Festival, a friend sent me an e-mail, said he was in the crawl chain home, found that the code returned by the page is garbled, let me help him staff staff (Mid-Autumn Festival overtime, really dedicated = =!) In fact, I met
Python Five types of data
In the process of learning a language, the first thing is to first touch the data type that it has, Python has five main data types, and here's what I understand and think about these five types of data.
1. Number
The
Tips for efficient file I/O operations in Python,
How to read and write text files?
Actual Case
A text file encoding format has been straight (such as UTF-8, GBK, BIG5), respectively in python2.x and python3.x how to read these files?
Solution
The
The python script automatically generates the required file instance code,
Python scripts automatically generate required files
In our work, we often need to write another file through one file. However, since it is a corresponding relationship,
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