Day01 Foundation One
I. OverviewC Language code compilation Gets the machine code, executes directly on the processor, each instruction controls CPU work other languages code compiles the bytecode, the virtual machine executes the bytecode and translates it to its code and then to the processor execution java virtual machine JVM python virtual machine Pvmpython version CPython Implemented by the C language, the official version Jpython is implemented by Java, with the benefit of a lot of Java libraries IronPython implemented by C # & nbsp .... 2.7 version over version, only supported by 2020, will be changed directly to at least 3.4 version 2 version and 3 version changes such as 2 in print ' 123 ' to 3 is print (' 1 ') print (' 11 ', ' 12 ') 2 need to first declare the character encoding in order to write Chinese, and 3 directly can be 2 and 3 some library names changed, case twisted does not support 3 install 3.5 and 2.7 Dual version configuration environment variables Edit path Add path directory include #!/usr/bin/python in c:\\python27 linux code Specify the interpreter to be able to./*.py Execute #!/usr/bin/env python This is better, avoid the situation where the version is not /usr/bin Tools Pycharm Community free pycharm Press and hold ctrl+d copy Line tab indent Select Multiline press tab multiline indent, shift +tab Reverse Indent Press CTRL + A method,You can see the source code variables of the method are labeled with meaningful names complex name underscores using son_of_twins_brother or Hump method Sonoftwinsbrother
- Variable names can only be any combination of letters, numbers, or underscores
- The first character of a variable name cannot be a number
- The following keywords cannot be declared as variable names
[' and ', ' as ', ' assert ', ' Break ', ' class ', ' Continue ', ' Def ', ' del ', ' elif ', ' Else ', ' except ', ' exec ', ' finally ', ' for ', ' F ' Rom ', ' Global ', ' if ', ' import ', ' in ', ' was ', ' lambda ', ' not ', ' or ', ' pass ', ' print ', ' raise ', ' return ', ' try ', ' while ', ' WI Th ', ' yield ']
user,passwd = ' aaa ', ' 123 '
second, the encoding formatASCII one byte indicates a character, a byte of 8 bits a byte represents the maximum number 255 ASCII 127 characters are designed to be stored in another table, in the ASCII table has a position point, that is If an access Chinese character accesses a location in ASCII, and then connects to a table of Chinese characters if the link location crosses, the Unicode (Uniform Code, universal Code, single code) is a character encoding that is used on the computer when the language characters in different countries are garbled. Unicode is created to address the limitations of the traditional character encoding scheme, which sets a uniform and unique binary encoding for each character in each language, which specifies that the characters and symbols are represented by at least 16 bits (2 bytes), i.e. 2 **16 = 65536 in the original 1M English document. It becomes 2 m. UTF-8, which is the compression and optimization of Unicode encoding, does not use a minimum of 2 bytes, but instead classifies all characters and symbols: the contents of the ASCII code are saved in 1 bytes, the characters in Europe are saved in 2 bytes, and the characters in East Asia are saved in 3 bytes ... When the Python interpreter loads the code in the. py file, the content is encoded (default Ascill 2 version)Python development specification, with a maximum of 80 characters per line
third, user inputPython3.0 in user_input = input ("Input your Name:") print ("User input msg", User_input) 2.7 version of the notation User_input = Raw_input (" Input your Name: ") User_input = input (" Your Name: ")//Required input variable or number, direct input string will be error when entering password, use Getpass library import GETPASSPASSW Ord = Getpass.getpass (' Input pass: ')
Iv. use of modulesOs.system () Returns the result of the execution first, and then returns a successful return 0 error returning another number such as Aa=os.system () then AA will only save the returned status number AA = Os.popen ("Df-h"). Rea D () can save the results of the command executionpath of module storage Sys.pathIt's usually in Python2.7/site-packages .or Usr/lib/python2.7/dist-packages .The first bit in the Sys.path list is the current directory, then the order of the modules is searched by the Sys.path list, and the current directory is found, and one does not continue to be searched.Tab Completion Code
#!/usr/bin/env Python # python startup file import sysimport readlineimport rlcompleterimport atexitimport os# tab complet Ion Readline.parse_and_bind (' Tab:complete ') # history file Histfile = Os.path.join (os.environ[' HOME '), '. pythonhistory ') Try:readline.read_history_file (histfile) except IOError:passatexit.register (Readline.write_history_file, Histfile) del os, Histfile, ReadLine, Rlcompleter
v. Formatting stringsPosition character%s string%d number%f floating point pip install readline use PIP installation #pip python install will have, need to configure environment variable PIP also has version The difference
Vi. Basic If judgment and cyclic statementsIf elif else loop for I in range (10): Remove values from range one by one to assign values to I break and continue while dead loop while True:print ' 123 ' online draw stream Partogram processon.com
Python Automated Operations Training learning record-day1