2016.5.211. All objects:Objects in Python, object types are assigned similar to C language pointers2. Number types
Decimal将相应的函数改名使用:from decimal import Decimal as D eg:D(‘0.3‘)/D(3)统计运行时间:python -mtimeit -s "from decimal import Decimal
is a toolkit to make the import list more beautiful, the official example is as follows:BeforeFrom My_lib import objectprint ("Hey") Import osfrom my_lib import object3from my_lib import object2import sysfrom Third_par Ty import Lib15, lib1, Lib2,
1. Time
The first is the way the timestamp is (relative to the offset from 1970.1.1 00:00:00 in seconds), the timestamp is unique
Time.time ()
The second is represented as an array of (Struct_time), a total of nine elements,
Print progress bars and percentages at the same time in PythonPrint progress bar only:Import Sys,time for in range: sys.stdout.write ('>') Sys.stdout.flush () time.sleep (0.1)Effect:Print percent:Import Sys,time for in range:
Dict in Python enables quick lookups. So is there a two-dimensional dictionary like an array with two-dimensional arrays? For example, I need to search for two keywords. The dict can bedict_2d = {'a': {'a'b' b': {'a': 6}}To build, and
Pip is used to conveniently manage Python's third-party package, since playing Python is just a scratch, using Python (x, y), but this does not mean that you want to use what package can be found from the inside, so I put Python (x, y) unloaded,
1.set set 1.set method resolution 1. Define a set" caesary " = Set (S1)print= [1,2,3,4= set (L1)print= (1,1,1,2,3= set (t1)print(SET3)Execution results are as follows{'y'e's'R 'c'a'} {1, 2, 3, 4 } {1, 2, 3}Summary: The set set has a redo function,
Intersection of Arrays IIGiven the arrays, write a function to compute their intersection.Example:Given nums1 = [1, 2, 2, 1] , nums2 = [2, 2] , return [2, 2] .Note:
Each element of the result should appear as many times as it shows in both
Common exceptionsAttributeerror attempts to access a tree that does not have an object, such as foo.x, but Foo has no attribute xIOError input/output exception; Basically, the file cannot be openedImporterror cannot introduce modules or packages; it
1 Determine if there are numbers in a stringI.isdigit () ==true else False #判断是否是数字I.isalpha () ==true else False #判断是否是字母I.isspace () ==true Else False # to determine if there are spacesdef string (STS): nums=0; st=0; kong=0; num={};
At present, Python provides several ways to implement multi-threading thread,threading,multithreading, where the thread module compared to the bottom, and the threading module is the thread to do some packaging, can be more convenient to be
Python file operations,
File objects in python:File objects can be used not only to access common disk files, but also to access any other types of abstract files.". Once an appropriate" Hook "is set, you can access other objects with file type
Python tutorial chapter 7, data structure, python Chapter 7
Python has three built-in data structures: List, tuples, and dictionary.1) Lists List [,]A list is a sequence.
shoplist = ['apple', 'carrot', 'banana']
print shoplist #['apple', 'carrot',
Python implements the SMTP mail sending function and pythonsmtp mail sending
I always wanted to add the mail sending function to the framework, So I sorted out the mail sending function in python.
First, python isSupports sending emails, built-in
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