1 #Import SQLite driver:2>>>ImportSqlite33 #Connect to the SQLite database4 #The database file is test.db5 #If the file does not exist, it is automatically created in the current directory:6>>> conn = Sqlite3.connect ('test.db')7 #Create a cursor:8>>
1. Use a recursive function to print the five characters you have entered in reverse order#-*-Coding:utf8-*-# AUTHOR:WXQ#python 2.7#题目: The 5 characters entered are printed in reverse order using the recursive function invocation method.#定义一个字符串,
In Python programming, raise can deliver errors, and the conditions for error can be customized by the programmer himself. In object-oriented programming, it is possible to reserve a method interface that is not implemented in its subclasses . If it
1. Dictionary operationA dictionary of Key-value data types.Grammar:1info = {2 'Car01':"Camry",3 'Car02':"Teana",4 'car03':"Accord",5}Features of the dictionary:
Dictionaries are unordered.
Key must be a unique
Increase>
When we use the buffer type in Python, we can convert it to the STR type.If the type of OBEJCT is , you can use STR (object) to convert it to a string type.If you cannot use the + string after converting to a string type, it is possible that
classFoo:def __init__(self,name): Self.name=namedef __getitem__(self, item):Print(self.)__dict__[item])def __setitem__(self, Key, value):Print('obj[key]= Vlaue when I do') self.__dict__[key]=valuedef __delitem__(self, key):Print('del Obj[key] when I
Inside the function we can call other functions such as:def say (Great): return Great def Person (name): Print (Say ("Hello"), name) person (" Sandichicks ")Print as follows:>>> Hello SandichicksBut if we call ourselves, this function is a
Pythonnet Network 1ARPAnet (Internet embryonic)---> CivilISO (International Organization for Standardization)---> Network Architecture standard OSI modelOSI: Network information transmission complexity requires a lot of functional
1. Self represents an instance of a class object itself. If you use Staticmethod to ignore this self, use this method as a normal function.2. The CLS table is the class itself.#code for ProofclassA (object):deffunc1 (self):Print("func1:", self)
The virtual environment represents the reconfiguration of all third-party packages under the new directory.Usage scenarios:1. If the existing (Anaconda environment or pycharm environment "vs. auto-read Related configuration") installs third-party
Python3.2 started, the standard library provides us with the Concurrent.futures module, which provides Threadpoolexecutor and Processpoolexecutor two classes, which enables further threading and multiprocessing Abstraction, which provides direct
There are two ways to format strings in Python3:% and formatOne,%Place a string on the left side of the% operator that needs to be formatted, with one or more embedded translation targets, beginning with%, such as%s,%d,%f.Place an object to the
Arithmetic operators
operator
Description
Example
+
Add-Two objects added
A + B output result 30
-
Minus-get negative numbers or one number minus the other
-B Output
before?? Can - iterators and generatorsThe main contents of this section :1. iterators2. builder ? . iteratorsWe were in front of you. Iterate the object into the iteration operation . So what exactly is an iterative object . this section
import bz2ImportError: No module named bz2Generally, when you manually compile Python, the dependent libraries that are not fully integrated on the compiled machine are incomplete.To install the bZIP library, use the following command:You can then
"" "# String index with slice # string All operations will not change the original string, will only generate a new string s =" ABCDEFGHIGKLM "S1 = s[0] Print (S1) # Gu Tou disregard tail string slicing S2 = s[0:2] Print (s2) s3 = s[:] # Get all
In : determine if a character is in a stringNot ni: determine if something is in somethingBase: convert to Binary bit_length : Binary of the current number, at least in several representations capitalize: Initial Capitalization if there are
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