Python self-study notes (1) A simple understanding of python, a self-study note to understand python
Internal Mechanism of script interpreted language
Python first compiles the script into a bytecode file (pyc, pyo)
The python Virtual Machine interprets and runs the bytecode File
Internal mechanisms of compiled languages
Compile the source code into machine code (code that can be understood by the machine) to generate executable files.
Run executable files
Therefore, compiled languages are superior to interpreted languages in terms of performance and running speed.
1. python features Overview
1. python is an interpreted language.
2. Feature Summary: bytecode, dynamic semantics (data type determined during assignment), four spaces indent
3. Everything in python is an object, because the reality involves a series of data and a whole of methods for operating the data, it is called an object.
4. the proud conclusion in a book: everything in python is a pointer, so you don't have to worry about the pointer.
5. Zen about python
Beautiful is better than ugly
Clear is better than obscure
Conciseness is better than complexity
2. No rule is perfect
# Coding = UTF-8 # coding must be defined in advance when there are Chinese characters in the single-line annotation code (spaces are not allowed on the left of the equal sign) "This is the writing paradigm of a standard module script, here is the script document comment "'single quotes annotate'" Double quotation marks annotate' "'" single quotes include double quotation marks "'" multi-line comment, newline 'can contain single quotation marks' "contains double quotation marks" print 'Hello world'
D = 4 # assign integer object 4 to variable d
1. If you don't remember it, it will be finished.
1.1 remember: all data is an object
1.2 remember: all variables are a reference to the data object (only the memory address is saved, no data is saved)
1.3python internal reference count: import sys. getrefcount ()
Reference: when the current data object is assigned a variable, the variable references the data object.
The reference count of python starts from 3 instead of 1.
# Coding = UTF-8 import sys # import sys module a = '000000' print sys. getrefcount ()
2. variable naming rules
2.1 remember what you can do only, starting with a letter
2.2 remember what can't be done, cannot use keywords
2.3 The most reasonable combination: lower-case file name, lower-case variable, and lower-case function name _ make the variable clearer
2.4 case sensitive
3. assign values
3.1 remember Dynamic Features
3.2 multiple values: a, B, c = "str1", "str2", 4
3.3 Delete del a and delete del B, c
4. Life
Three built-in must use familiar type, help, dir