"Concise python tutorial" is a good online Python entry-level tutorial, although the version is relatively old, but the basic explanation is very powerful.
ch2– install Python: After the download installation is complete, in the system environment variable, after the path variable appends the address of the installation directory, can use the python under the cmd;
Ch3–python3, print syntax changed to print (); Python editor list; python-enabled IDE list;
The ch4– variable does not require a special variable type definition process;
ch5– arithmetic expression and priority;
ch6– control Flow, the main control statement line end with ":" End; the use of if/while/for/break/continue;
ch7– Use Def fun (A, B): To create a function, return the function value using return;
ch8–import/from...import/; Use __name__ to invoke the name of the module;
ch9– data structure, list, tuple, dictionary dictionary, sequence, string manipulation;
ch10– a Python script instance;
ch11– Defining Class * * * *
Defining a function in a class DEF * *
Initialize Class Def __init__ (self,x,y) self.x=x self.y=y
Inheriting class: Class Class2 (Class1):
When you invoke the object's method MyObject.method(arg1, arg2)
, this is automatically converted by Python- MyClass.method(MyObject, arg1, arg2)
-that's how it self
works.
class Teacher (schoolmember): def __init__ (self, name, age, salary): Schoolmember. __init__ (self, name, age) = salary print'(Initialized Teacher:%s)' % self.name
ch12– file operation, files () is changed to open () in Python3;
The file reads the print instance line by row;
f = File ('poem.txt') while True: = f.readline () if # Zero length indicates EOF Break Print (line) f.close ()
Ch13–try. Except. else used to handle exceptions, except to indicate exceptions, else to indicate normal conditions; Finally: Indicates that the final action, regardless of the try result, will execute finally:
Ch14–python Standard library: Use of SYS.ARGV, OS module;
Ch15–python some special methods; Assert statements;
__init__(Self,...)#This method is called before the new object is returned to use. __del__(self)#called exactly before the object is to be deleted. __str__(self)#called when we use the PRINT statement on an object or use STR (). __lt__(Self,other)#called when the less-than operator (<) is used. Similarly, there are special methods for all operators (+,>, and so on). __getitem__(Self,key)#called when using the X[key] index operator. __len__(self)#called when using the built-in Len () function on a Sequence object.
ch16– Advanced Learning Content
The Concise Python Tutorial study notes